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
8 Respostas
+ 1
I give <a> to be 1 and < b> to be + but <c> doesn't run
+ 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 ...
+ 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
+ 1
Ok..ok..I see..thanks a lot
Am still a beginner
0
An example of description is above
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 ...
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
0
Tumhare maa ko kaise chodu bataoo