input n space separated integers in c 2b 2b

Solutions on MaxInterview for input n space separated integers in c 2b 2b by the best coders in the world

showing results for - "input n space separated integers in c 2b 2b"
Marianna
18 Mar 2020
1int main() {
2int sum = 0;
3cout << "enter number" << endl;
4int i = 0;
5while (true) {
6    cin >> i;
7    sum += i;
8    //cout << i << endl;
9    if (cin.peek() == '\n') {
10        break;
11    }
12    
13}
14
15cout << "result: " << sum << endl;
16return 0;
17}
18