help with making a historgram

hi everyone, im tasked with making a program that allows you input a number (cant accept a negative #) and displays a histogram. you should be able to keep inputing numbers until you enter a negative oen to quit by using loops
example: i input the number 5 and it should display
*****
Thanks
Last edited on
Do you know how to allow the user to input a number? To display the asterisks you could use a loop.
Yes, but the issue is im not sure on how to code the loop to make it display the output
Do you know how to write a loop that runs a certain number of times?
A for() loop which runs the requisite number of times and has the single content
cout << "*";

After the loop make sure you use cout again to get a new line.
Last edited on
I know how to allow the user to exit by inputing a value or until a value is false.
I know how to allow the user to exit by inputing a value or until a value is false.


So please could you show us your current code and state which part you are having problems with.

Note that, if you are developing this from scratch, then it would probably be best to just ask for a single number first and draw the histogram bar. Once that is working correctly you can put a loop around it and ask for multiple numbers. Try to do one thing at a time.
Topic archived. No new replies allowed.