#include <iostream>
#include <vector>
usingnamespace std;
int main()
{
double tempHolder, sum = 0.0;
vector<double> list;
for(int i = 0; i < 10; i++)
{
cin >> tempHolder;
list.push_back(tempHolder);
}
for(i = 0; i < 10; i++)
{
sum += list[i];
}
cout << sum << endl;
return 0;
}
I know this may be advanced for what you are doing. You seem to me like a beginner, so this code will either make your teacher think you are a genius, or that you got this from somewhere. Enjoy :)
#include <iostream>
int main()
{
double sum = 0.0;
for (int i = 0; i < 10; i++) {
double input;
cout << "type in number " << i << "#: ";
cin >> input;
sum += input;
}
cout << "Sum is " << sum << endl;
return 0;
}
Since this topic is worthless anyway, allow me to derail.
I actually was called "a genius" by a teacher once in elementary. She was giving a complicated question -- possibly a sort of brainteaser -- and I, realizing this, thought "what the hell. I'll do it in my head." I can't quite remember how long it took me, but it must have been 5-10 seconds.