Nested loop –
Another Example
n
*
n
* *
n
* * *
n
* * * *
n
* * * * *
n
One counting variable (i) to record how many lines
n
Another counting variable (j) to record how many stars in each line
n
One Solution:
for (i = 1; i <= 5; i++) {
// control how many lines
for (j = 1; j <= i; j++)
// control how many stars in each line
cout << "* ";
cout << endl;
}