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, 22.06.2019 14:50
Drag each label to the correct location on the image list the do’s and don’ts of safeguarding your password. a. keep yourself logged in when you leave your computer.b. don’t write your password down and leave it where others can find it.c. share your password with your friends.d.each time you visit a website,retain the cookies on your computer.e. use a long password with mixed characters.1. do's 2. don'ts
Answers: 2
question
Computers and Technology, 22.06.2019 16:30
The most common battery cable terminal is a that provides a large surface contact area with the ability to tighten the terminal onto the battery post using a nut and bolt.
Answers: 2
question
Computers and Technology, 22.06.2019 21:00
So im doing this school challenge and the teachers said whats the average text a student gets a day so i need to get about 20 in a day but dont know how can you guys 2163371293
Answers: 2
question
Computers and Technology, 23.06.2019 06:30
Which option correctly describes a dbms application? a. software used to manage databases b. software used to organize files and folders c. software used to develop specialized images d. software used to create effective presentations
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
Mathematics, 28.11.2020 02:50
question
Mathematics, 28.11.2020 02:50
Questions on the website: 13722361