Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

input n space separated integers in c++

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;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #input #space #separated #integers
ADD COMMENT
Topic
Name
9+7 =