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

Use of Recursion