You're welcome to change the appearance of these, or produce something a little different. The point of this is to give you practice with loops and functions, so show what you can do.
******* ******* *******
Sample solution.
int width, height; while (cin >> width >> height) { for (int row=0; row<height; row++) { for (int col=0; col<width; col++) { cout << "*"; } cout << endl; // end the line of stars. } }
* ** *** **** ***** ******Here is a solution.
int size; while (cin >> size) { for (int row=1; row<=size; row++) { for (int col=0; col<row; col++) { cout << "*"; } cout << endl; // end the line. } }
* ** *** **** ***** ******
if
statement to test for first or last row of first or last column, in
which case a star is printed, otherwise print a blank.
******* * * * * * * *******
Print a pyramid. Read (in a loop of course) a number, n, and print a pyramid that has that size. The example below shows what would be printed for n=4.
* * * * * * * * * *
* ** *** **** ***** ****** ***** **** *** ** *