Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please attach a screenshot of the code in the editor, Thank you! Write a program (Q2.cpp) that asks the user to provide a character and

image text in transcribed

Please attach a screenshot of the code in the editor, Thank you!

Write a program (Q2.cpp) that asks the user to provide a character and an integer between 1 and 100 and prints a "pyramid" on the screen, composed of the chosen character and with the chosen number as height. Upon receiving an invalid height, the program shouldn't exit but it should print an error and ask the user to input another value (see sample run below). An invalid height is a number higher than 100, a negative one, zero, or a value that is not a number (e.g.. 'a'). You can disregard the case in which the user inputs a decimal number. Sample run 1 Enter a character: Enter a height (between 1 and 100):5> Sample run 2: Enter a character: Enter a height (between 1 and 100):6> Sample run 3: Enter a character: Enter a height (between 1 and 100): Error! You specified an invalid height! Enter a height (between 1 and 100):3>

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Students also viewed these Databases questions

Question

List the advantages and disadvantages of the pay programs. page 505

Answered: 1 week ago