Problem 7: Pyramid Of Numbers 1 Solution

The pattern of this solution is similar to that of problem 6. Nevertheless, there are some essential differences:

  1. The inner loop is a function of the outer loop: the inner loop's test uses the outer loop's control variable. This "trick" is how we get the inner loop to iterate or run a different number of times, printing more characters in each subsequent line
  2. This problem calls for printing out a value based on the loop control variable rather than just printing an unchanging character
  3. Both loops begin at 1, and the test (the middle expression) uses less than or equal to (<=) rather than just less than. We do this to make it easier to print the required value based on the loop control variable
for (int row = 1; row <= 7; row++)
{
	for (int col = 1; col <= row; col++)
		cout << row;
	cout << endl;
}