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:
-
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?
-
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started