Question: Write c++ Patterns, by using for loops (Task 1) Create a staircase with increasing numbers at each step up until numSteps: Example for numSteps ==

Write c++ Patterns, by using for loops

(Task 1) Create a staircase with increasing numbers at each step up until "numSteps":

Example for numSteps == 4

1

12

123

1234

(Task 2) Create a horizontal Pyramid to a maximum height of "heightPyramid". The height of a row is the horizontal distance from start till the end of the row in the Pyramid.

Example for heightPyramid == 3

\\

\\\\

\\\\\\

\\\\

\\

(Task 3: Extra Credit) Create a Diamond with a maximum height of "heightDiamond". The height here is the vertical distance from the first row to the last row of the diamond. For ease, only consider even values for the height.

Example for heightDiamond == 6

/\

/ \

/ \

\ /

\ /

\/

Hints:

  1. Can you figure out the number of spaces between the start of the row and the first slash? Can it be expressed as a function of the current row of the diamond and the height of the diamond?

  2. The number of spaces between the first and second slash can be expressed as twice of a certain variable. Can you figure out the exact formula for it?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!