Problem 6: Box Of *'s Solution

The solution for problem 2 is essentially a combination of the solutions for problem 5: The inner loop prints one line of *'s; since all the output must appear on a single line, the endl must be outside the inner loop. The outer loop drives the inner loop, working from the top of the box to the bottom. The outer loop contains two statements: (a) the inner loop and (b) the cout statement. The braces form a block or compound statement, so the outer for-loop is a single statement.

for (int row = 0; row < 5; row++)
{
	for (int col = 0; col < 5; col++)
		cout << '*';
	cout << endl;
}