0

I am having trouble with making you have to input multiple values. How can I do that?

here is my code #include <iostream> using namespace std; int main() { int symbol; int num1; int num2; cin >> symbol; if(symbol > 0 && symbol < 6) { cin >> num1; cin >> num2; if(symbol == 1) { cout << "you chose to add" << endl << num1 + num2; } }else { cout << "choose a number from 1 to 5" << endl; } return 0; }

9th Mar 2017, 1:27 PM
Joseph Ceci
Joseph Ceci - avatar
6 Respuestas
+ 6
There's actually no problem with your code. If you are trying sololearn compiler give input in new line like 1 5 5 and not 1 4 5
9th Mar 2017, 1:32 PM
Megatron
Megatron - avatar
+ 6
Sololearn is online compiler it would ask for all values at once without any prompt. just try input as enter 1. hit enter(go-to next line) enter 6 hit enter(go-to next line) enter 7 and then tap submit.
9th Mar 2017, 1:38 PM
Megatron
Megatron - avatar
+ 4
your code work well. If you use Sololearn compiler, try to enter your input on the separated line. If you want to try the real case, you can try to compile it on your own PC.
9th Mar 2017, 1:42 PM
Dadang NH
Dadang NH - avatar
+ 1
Your code should work, did you write all your inputs or just one ?
9th Mar 2017, 1:31 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
0
the code is only lett7ng me input 1 value though. I don't know how to make it so that the user has to input multiple values
9th Mar 2017, 1:35 PM
Joseph Ceci
Joseph Ceci - avatar
0
Oh wait thanks I understand now
9th Mar 2017, 1:37 PM
Joseph Ceci
Joseph Ceci - avatar