0

Operator problem

can anyone can explain why the math operator can't appear like this code: #include <iostream> using namespace std; int main () { int a; int b; int c; int math; cout << "enter the first number" << endl; cin >> a; cout << "enter the second number" << endl; cin >> b; cout << "enter the third number" << endl; cin >> c; cout << "enter the operator" << endl; cin >> math; cout << a << "x " << math << b << " = " << c << endl; return 0; } if you enter the operator like '+' the output is 0 not '+ ' why?please help me.

20th Oct 2018, 6:54 AM
Alpha
Alpha - avatar
1 Odpowiedź
0
math is an int variable, not a char so it is displayed as a number instead of a character
28th Aug 2022, 5:51 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar