Hi all,
Ok, so I am new to C++ and whilst I understand most of the theory, I am still struggling with the practical applications! I'm trying to write a program that will allow a user to enter 10 whole numbers, then return the sum of all 10 numbers, the sum of the positive numbers and the sum of the negative. At the moment I have:
#include <iostream>
using namespace std;
int main()
{
int one, two, three, four, five, six, seven, eight, nine, ten;
int count;
cout << "This program accepts 10 integer numbers, the returns\n";
cout << "the sum of all positive numbers, the sum of all negative\n";
cout << "numbers and the sum of all the numbers." << endl;
cout << "Enter 10 whole numbers, each followed by 'Enter': \n ";
cin >> one >> two >> three >> four >> five >> six >> seven >> eight >> nine >> ten;
cout << endl;
cout << "The sum of all 10 numbers = ";
cout << one + two + three + four + five + six + seven + eight + nine + ten;
cout << endl;
return 0;
}
Obviously the sum of negative and positive are missing. I know I need some kind of loop that will check if 'int one. . .ten' is positive or negative and add their values to two new totals, but I can't seem to figure out the structure.
Any help would be great. I'm not looking for the code, just someone to point me in the right direction.
Many thanks.