how loops work c++ code example
Example 1: for loop in c++
for ( int i = 0; i < 5; i++)
{
cout << "Hello" << endl;
}
// prints hello 5 times.
Example 2: for c++
for (int i = 0; i < 7; i++)
{
cout << i << endl;
}
for ( int i = 0; i < 5; i++)
{
cout << "Hello" << endl;
}
// prints hello 5 times.
for (int i = 0; i < 7; i++)
{
cout << i << endl;
}