Question: C++ please 1. Write a program that displays a histogram based on a number entered by the user. For example: Enter a number: 5 5:
C++ please
1. Write a program that displays a histogram based on a number entered by the user. For example:
Enter a number: 5
5: *****
Enter a number: 2
2: **
Write the program once with a while loop and again with a for loop.
2. Write a program that computes the factorial of a number. For example, 5! = 5 * 4 * 3 * 2 * 1 = 120. Turn the program into a function and use the function in a program.
Write the program once with a while loop and again with a for loop.
3. Write a program that validates input for a program. For this program, the input should be between 1 and 10. If the user enters a value less than 1 or greater than 10, the user should be asked to enter the value again until it is within the range.
Use a while loop for this program.
4. Turn problem 1 into a void function and use the function in a program. The function should accept the number to display as an argument:
histo(3) displays:
3: ***
Use a for loop for this program.
5. Write a program that sums a set of numbers entered by the user until the user enters -666, at which point the program displays the sum.
Use a while loop for this program. Could you write it with a for loop? Try it to see.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
