+ 1

Variables values question

#include <iostream> using namespace std; int main() { int a, b; int sum; cout << "Enter a number \n"; cin >> a; cout << "Enter another number \n"; cin >> b; sum = a + b; cout << "Sum is: " << sum << endl; return 0; } The above code is supposed to let me input two values I.e for the variables a and b before it sums it but when I tried it, it just gives the opportunity to enter one value and gives me a sum immediately. Please why is this

15th Jun 2019, 1:06 PM
Chidi Anioke
1 Answer
+ 1
In SoloLearn you need to enter all the values at once, one on each line.
15th Jun 2019, 1:11 PM
Maxim Balakirev
Maxim Balakirev - avatar