0

Why character is not come to my code.? I want to input operator bycharacter.

#include <stdio.h> main() { float a,b, result; char op; printf("first number ="); scanf("%f",&a); printf("Enter the operator= %c ",op); scanf("%c",&op); printf("\nsecond number="); scanf("%d",&b); return 0; }

1st Jun 2020, 10:12 AM
Abhishek Kumar
Abhishek Kumar - avatar
1 Réponse
+ 2
You try to output 'op' before scanning for it ('Enter...'). If you move The output under scanning for it, it should work!
1st Jun 2020, 12:28 PM
Sandra Meyer
Sandra Meyer - avatar