Solution: Loop It Up
The main() function uses two for loops, one to print a message repeatedly and another to display even numbers in a sequence.
The first
forloop initializesi = 0and runs whilei < 5, printing "Looping!" each time and incrementingiby 1.Prints an empty line using
cout << endl;to visually separate the outputs.The second
forloop starts withi = 0and increasesiby 2 on each iteration (i += 2), printing all even numbers from 0 to 10.Ends with
return 0;to signal successful program completion.
Solution: Loop It Up
The main() function uses two for loops, one to print a message repeatedly and another to display even numbers in a sequence.
The first
forloop initializesi = 0and runs whilei < 5, printing "Looping!" each time and incrementingiby 1.Prints an empty line using
cout << endl;to visually separate the outputs.The second
forloop starts withi = 0and increasesiby 2 on each iteration (i += 2), printing all even numbers from 0 to 10.Ends with
return 0;to signal successful program completion.