+ 3
Can anyone explain why this code is not working..? 🙄
#include <stdio.h> #include <stdint.h> int main() { float num1; float num2; char op; float result; printf("Enter first value :"); scanf("%f",&num1); printf("Enter operator :"); scanf("%c",&op); printf("Enter second value :"); scanf("%f",&num2); switch(op) { case '+' : result = num1+num2; printf("%f",result); break; case '-' : result = num1-num2; printf("%f",result); break; case '*' : result = num1*num2; printf("%f",result); break; case '/' : result = num1/num2; printf("%f",result); break; } return 0; }
2 ответов
+ 3
Add a space prior to %c to consume the remaining whitespace character from the previous scanf.
scanf(" %c",&op);
+ 6
Try using #include<stdlib> in place of <stdint> it works.. you can refer this..made some changes :)
https://code.sololearn.com/cHZ8j558dr87/?ref=app