Write a c++ program to display numbers from 1 to infinite by using for loop .

 


/* Write a c++ program to display numbers  from 1 to infinite by using for loop  */


#include <iostream>

using namespace std ;

int main()

{  

    int i, n ;

/* note : for making infinite loop ,there must be  such a condition which never be wrong  ex : 2>1 */

for(i= 1; 2>1 ; i++) // 2>1 always true 

  {  cout<< i <<"  ,  "; }

   return 0;

}


output 

1, 2  ,3, 4 ,5,..........................infinite   more exercise



Comments

Popular posts from this blog

Write a program to reverse the string. input = google output = elgoole */

Write the program to make substring of a string.

Write a c++ program to display numbers which is divisible by 2 as well 3 from 6 to n by using and operator .