Problem 5: Loops Solution

The first for-loop draws a single line of asterisks. The endl statement is inside the loop, meaning that the program follows each * with a new line character. The code fragment consists of a single statement terminated by a single semicolon, and the output is a vertical stack of *'s:

*
*
*
*
*

The second for-loop draws a single line of asterisks. As the indentation suggests and the semicolons implement, cout << '*' is inside the loop, but cout << endl is outside, meaning that the program prints each * on the same line. So, the code fragment consists of two statements terminated by two semicolons, and the output is a horizontal line of *'s:

*****