For some reason, I'm not able to sum the elements in my vector. When I run the program, the console only prints out the first element. For example, if my input is: 12 23 45 56
(all in one line), the output is 12
.
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <numeric>
using namespace std;
int main() {
vector<int> myVector;
int numberOfValuesToSum = 10;
int vectorValues = 0;
int sum = 0;
// cout << "Please enter the number of values you want to sum: ";
// cin >> numberOfValuesToSum;
cout << "Please enter some integers: ";
cin >> vectorValues;
myVector.push_back(vectorValues);
for (int i : myVector) {
sum += i;
cout << sum << endl;
}
}