0

I'm trying to make a simple calculator but my code has no output pls help

#include <stdio.h> int main() { int x, z; char y; scanf("%d", &x); scanf("%c", &y); scanf("%d", &z); if(y == '+') { printf("%d", x+z); } else if(y == '-') { printf("%d", x-z); } else if(y == '*') { printf("%d", x*z); } else if(y == '/') { printf("%d", x/z); } return 0; } ^^^ This is my code

26th Mar 2024, 6:26 AM
ImMyth
ImMyth - avatar
4 Answers
+ 1
Ayush adding space before %c fixed it ty
27th Mar 2024, 6:09 PM
ImMyth
ImMyth - avatar
0
or this scanf("%d %c %d ", &x,&y,&z);
26th Mar 2024, 7:41 AM
Bob_Li
Bob_Li - avatar
0
scanf (" %c",&y);
27th Mar 2024, 4:52 PM
Alhaaz
Alhaaz - avatar