Use C++ please. Thank you
Write a program that achieves the following requirements: A while/do-While loop that will ask the user to input an integer on each iteration. The loop keeps a running total of the input and exits only when the total exceeds the first input times 10. A for loop that does the exact same thing. The program should print out the “new total each time the total is input.
Expert Answer
1.
#include<iostream> using namespace std; main() // taking user input of first number // taking user input if total hasn’t reached 10 times first total += temp; } |
Enter a number : 123 Enter a number : 12 Enter a number : 23 Enter a number : 100 Enter a number : 1000 |
2.
#include<iostream> using namespace std; main() // taking user input of first number } |
Enter a number : 123 Total is 123 Enter a number : 12 Total is 135 Enter a number : 23 Total is 158 Enter a number : 100 Total is 258 Enter a number : 1000 Total is 1258 |