C++ For Loop

Master C++ with Real-time Projects and Kickstart Your Career Start Now!!

Program 1

// for loop 
#include<iostream>
using namespace std;
int main()
{
   system("cls");
    int i=1;
   for(;;)
   {
     cout<<i<<endl;
     if(i==10)
       break;
     i++;
   }


   return 0;

}


//    int i=1;
//    for(;i<=10;i++)      
//    cout<<i<<endl;

//  int i;
//    for(i=1;i<=10;)      
//    {
//      cout<<i<<endl;
//      i++;
//    }

//  for(;i<=10;)      
//     {
//        cout<<i<<endl;
//         i++;
//     }

Program 2

// for loop 
#include<iostream>
using namespace std;

int main()
{
   system("cls");
   int i;
    for(i=1;i<=10;i++)
    {
        if(i==5)
        continue;
        cout<<i;
        cout<<" Hello"<<endl;
    }
return 0;
   }

Did you like this article? If Yes, please give DataFlair 5 Stars on Google

courses

DataFlair Team

DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.

Leave a Reply

Your email address will not be published. Required fields are marked *