+ 2
help
when I subtract comes up with a random number but when I add it comes with the right answer please help me #include <iostream> using namespace std; int main() { int a; int b; int sym; int sum; int sub; cout<<"put numder\n"; cin>> a; cout<<"put another number\n"; cin>> b; cout<<"are you adding(1) or subtrating(2) \n"; cin>> sym; cout<<"output\n"; if (sym = sum){ sum = a + b; cout<< sum; } if(sym = sub){ sub = a - b; cout<<sub; } return 0; }
3 Respostas
+ 2
sym is of int data type. It can accept integer data. So for addition it must accept 1 and for subtraction it must take 2 as input. In the condition checking for calculation make it if(sym ==1) for addition and if(sym==2) for subtraction.
+ 1
nice programs
0
thanks I forgot that have to put two =