int main() { int sum = 0; cout << "enter number" << endl; int i = 0; while (true) { cin >> i; sum += i; //cout << i << endl; if (cin.peek() == ' ') { break; } } cout << "result: " << sum << endl; return 0; }