Lab 2: Print Shapes

For this lab we will create a pattern maker program using loops.

The lab is broken down into 4 steps.

In Codio, we have provided the main() function, and you will write the code for each step and then call them using the given options to check your lab output.

Please complete the lab in pairs.

 you will write each stage in a separate .cpp file. Codio should open the files automatically for you, and keep the code so we can confirm your code with the checks.

Stage 0: (0 Points)

Write code that prints one asterisk.

Sample Output:

  *

Stage 1: (1 Point)

Write code to accept as input a number (n) at the prompt

     Please enter a number:

The function should print an asterisk '*' n times.

Running the program should look like:

  Please enter a number: 3

  * * *

 

Stage 2: (1 Point)

Write code to accept a number(n) at the prompt

     Please enter a number:

The function should print an asterisk '*' as a square where each side is of size n.

Running the program should look like:

  Please enter a number: 3

  ***

  ***

  ***

Stage 3: (1 Point:Extra Credit)

Write code to accept a number(n) at the prompt

     Please enter a number:

The function should print an asterisk '*' as a right triangle of height n.

Running the program should look like:

  Please enter a number: 3

  *

  **

  ***