Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please solve using c++ and make sure it runs using vim Console Graphics: A Triangle We can approximate drawing a triangle on screen by printing
please solve using c++ and make sure it runs using vim
Console Graphics: A Triangle We can approximate drawing a triangle on screen by printing out multiple copies of a single character at the right location. For a triangle, we can draw a single character on one line, followed by three on the next line, five on the next line, and so on. Here is an example of a triangle of height 5: #3 ### ##### ####### ######### Write a program that displays a triangle on the console. Prompt the user to enter an int corresponding to the height of the triangle and a char for the character to print. Allow the user to draw as many triangles as they wish. Program Requirements 1. Write a function called get_input that sets two variables based on the user's input: one for the height of the triangle, the other for the character to print. A valid height is any integer greater than zero. The function should test whether the user entered a valid height: if so, then the function should return true; if not, then the function should return false. 2. Write a second function called draw_triangle which takes two parameters (the height of the triangle and the character to print) and draws a triangle of the specified height using the character. Align the triangle such that the bottom row starts at the beginning of its line. 3. Use the function get_input to control whether or not to draw the triangle. 4. Use a do-while loop to control the overall program. After the first attempt at drawing a triangle, ask the user if they wish to do it again and allow them to do so until the user indicates they wish to quitStep 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