0
What is the error in this code?
I don't no what's the error in the following code please help me to solve this issue in this code https://code.sololearn.com/caZHsuNy3T5S/?ref=app
8 Answers
+ 3
You can leave the order the same just place a space before %c to catch the leftover '\n' character in the input stream.
scanf(" %c", &op);
+ 2
Hey PUNEETH M , I am not saying that I made this code correct but you need to understand the behaviour of operator, if else, char and Macro
PS: this code is only working for + operator cause I only define + Operator as Macro
https://code.sololearn.com/cpuUSX6GY6iF/?ref=app
+ 1
Change void into int
void main() to int main()
and your code gonna run smoothly
+ 1
Not working bro
+ 1
PUNEETH M
Plz change you code order to
printf("Enter the sign of operation:\n ");
scanf("%c", &op); // not %s , %c for char
printf("Enter the A: \n");
scanf("%d", &a);
printf("Enter the B: \n");
scanf("%d", &b);
now,it's working. tested!!
B.coz your code will work depending on the sign of operation ,so program need to check the sign first,I think
+ 1
ChaoticDawg is right,plz do correct your code like that
0
Thank you so much đ . If I give space for %c it's working but I did not understand logic behind the space before %c. Can you explain . Any way thank so much once again for Myo Thuzar and also to Saurabh Kumar Yadav