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; }
6 Answers
+ 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
+ 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.
+ 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.
+ 1
Your code should work, did you write all your inputs or just one ?
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
0
Oh wait thanks I understand now