0

Can someone tell me why my c++ can't take more than 2 inputs,on a separate line.I don't understand o

#include <iostream> using namespace std; Int main () { Int a; Int b; Int c; cout <<"This is a simple calculator"; cout<<"enter a number"; cin>>a; cout <<"enter an operator"; cin>>b; cout <<"enter another number"; cin>>c; return 0; } //let's just stop here.. The code only executes the first input, second input and leaves the third.returning 0 Am using codeblocks..what is the problem now

17th Sep 2020, 1:14 PM
Ugonna Muoneme
Ugonna Muoneme - avatar
8 Answers
+ 1
I give <a> to be 1 and < b> to be + but <c> doesn't run
17th Sep 2020, 9:46 PM
Ugonna Muoneme
Ugonna Muoneme - avatar
+ 2
Tell me what input was given please, all the variables are of `int` type, so you might want to check what input was given ...
17th Sep 2020, 2:38 PM
Ipang
+ 1
Attach your code link in the thread Description so people can review it, and suggest you something. https://www.sololearn.com/post/75089/?ref=app
17th Sep 2020, 1:19 PM
Ipang
+ 1
Ok..ok..I see..thanks a lot Am still a beginner
17th Sep 2020, 10:57 PM
Ugonna Muoneme
Ugonna Muoneme - avatar
0
An example of description is above
17th Sep 2020, 1:36 PM
Ugonna Muoneme
Ugonna Muoneme - avatar
0
I mean what input you provide the code when running it. The values you give for variable <a>, <b> and <c>. + DM doesn't work ...
17th Sep 2020, 9:30 PM
Ipang
0
Okay now I see the problem. `int` can only take numbers, when you give + for <b>, something wrong happened because '+' is not a number, and <c> got garbage because of the problem. You can use `char` to accept operation type. See the below code to see how char is used as operation specifier. https://code.sololearn.com/cJPIHNxY008y/?ref=app
17th Sep 2020, 10:27 PM
Ipang
0
Tumhare maa ko kaise chodu bataoo
19th Sep 2020, 8:24 AM
Vishwajit Thokane
Vishwajit Thokane - avatar