still new to c
#include <iostream>
using namespace std;
int main()
{
int num, sum = 0;
// loop will run 10 times from i=0 to i=9
for (int i = 0;i < 10;i )
{
// get number from user
cout << "Enter integer: "<< endl;
Am trying to asks the user for an integer ten times. Have the loop total the integers given. Show the total after the loop terminates
CodePudding user response:
Here's the remainder of your code:
// get number from user
std::cout << "Enter integer: " << endl;
std::cin >> num;
sum = sum num;
}
} // End: for
std::cout << "Total of all numbers: " << sum << endl;
return 0;
}
The code above shows how to input a number, sum (total) the numbers and then print the total (sum).