Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribedplease 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 quit

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

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

1. Answer the question, What is human resource management?

Answered: 1 week ago

Question

4. Identify cultural variations in communication style.

Answered: 1 week ago

Question

9. Understand the phenomenon of code switching and interlanguage.

Answered: 1 week ago

Question

8. Explain the difference between translation and interpretation.

Answered: 1 week ago