0
Why is it not working
#include <iostream> using namespace std; int main() { string a; int b,c; cin>>a; cin>>b; cin>>c;} if(a=="add"){ cout<<c+b; } if(a=="multiply"){ cout<<c*b; } return 0;
13 ответов
+ 6
I was facing issues earlier, I thought this could be the reason, seems like something else.. thanks for correcting.. this helps my learning as well..
+ 5
Thanks Timon Paßlick
+ 3
#include <iostream>
using namespace std;
int main() {
string a;
int b,c;
cin>>a;
cin>>b;
cin>>c;
if(a=="add"){
cout<<c+b;
}
if(a=="multiply"){
cout<<c*b;
}
return 0;
}
+ 3
Shobikaj Why do you need to ignore?
+ 3
Shobikaj With this input, it doesn't:
add
5
3
+ 3
Yes, if it is in space separated it throws an error..
+ 3
Shobikaj This also doesn't:
add 5 3
+ 3
Shobikaj Yes. You don't need to ignore.
+ 2
The flower bracket after int main() is closing Free cin >>c which actually should be after return 0;
+ 2
thanks
+ 2
Timon Paßlick to ignore new line char. it was throwing an error without it.
+ 2
It's is working now..🙄😶
+ 1
Also, since your using string you need to ignore cin. Please find the modified code.
https://code.sololearn.com/cNbE7UEx4t4o/?ref=app