subject

(C Language) Write a program to display a histogram based on a number entered by the user. A histogram is a graphical representation of a number (in our case, using the asterisk character). On the same line after displaying the histogram, display the number. The entire program will repeat until the user enters zero or a negative number. Before the program ends, display "Bye...".

The program will ask the user to enter a non-zero positive number. Using a while loop, validate that the number is not greater than 40, and if so, re-ask for the number. Put the entire program into a sentinel-controlled loop so that the user can enter either zero (0) or a negative number to end the program.

Create constants for 1 (the minimum number for the histogram), and 40 (the maximum number for the histogram), and use these constants in the prompts, the validation condition and error message, and the sentinel-controlled loop and the histogram loop.

Hints:

Validation messages are indented 3 spaces
You can use either a pre-test loop (with the initial prompt outside the loop, and the re-prompt at the end of the loop) or a post-test loop (with the prompt inside the loop, and a decision to print the histogram also inside to loop).
Coded the histogram using a for loop (although any type of loop could be used)
Example Run:

(bold type is what is entered by the user)

Enter a non-zero positive number less than 40: 5
5

Enter another non-zero positive number less than 40: 48
The number entered was greater than 40.
Please re-enter: 8
8

Enter another non-zero positive number less than 40: -1

Bye...

The example run shows EXACTLY how your program input and output will look.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 21:30
Enzo’s balance sheet for the month of july is shown. enzo’s balance sheet (july 2013) assets liabilities cash $600 credit card $4,000 investments $500 student loan $2,500 house $120,000 mortgage $80,000 car $6,000 car loan $2,000 total $127,100 total $88,500 which expression finds enzo’s net worth?
Answers: 1
question
Computers and Technology, 24.06.2019 11:00
Why is it uncommon for users to perform searches directly in database tables? a.)users are discouraged from interacting directly with tables because they might confuse tables with spreadsheets. b.) users are discouraged from interacting directly with tables because this may result in unintended changes to source data. c.)users do not have the technical skills required to perform searches directly in database tables. d.)users do not have the permissions required to perform searches directly in database tables.
Answers: 1
question
Computers and Technology, 25.06.2019 09:30
If a business owner wanted to create a banner ad for his business on his webpage, he could use java programming to develop a (n) spreadsheet cad software applet music application
Answers: 1
question
Computers and Technology, 25.06.2019 13:30
Landslides often accompany earthquakes and volcanoes and pose an additional threat to humans after these events. true false
Answers: 1
You know the right answer?
(C Language) Write a program to display a histogram based on a number entered by the user. A histogr...
Questions
question
Biology, 25.09.2019 01:30
question
Mathematics, 25.09.2019 01:30
question
Mathematics, 25.09.2019 01:30
question
Biology, 25.09.2019 01:30
Questions on the website: 13722367