cs161AWinter2024/forInput.cpp

22 lines
373 B
C++

#include <iostream>
using namespace std;
int main() {
double sum = 0;
int numThings = 0;
cout << "Enter the number of things to be summed: ";
cin >> numThings;
for(int i = 0; i < numThings; i++){
double temp = 0;
cout << "Enter a number: ";
cin >> temp;
sum = sum + temp;
}
cout << "Here's your final sum: " << sum << endl;
return 0;
}