+ 1
why it is not taking any char input
#include <stdio.h> int main() { int i,j; char n; printf("Enter the first num\n"); scanf("%d",&i); printf("Enter the second num\n"); scanf("%d",&j); printf("Enter the opration num\n"); scanf("%c",&n); if (n =='+'){ printf("%c",i+j); } return 0; } https://code.sololearn.com/cmNQ58TspuWH/?ref=app
1 Answer
+ 3
Add a space before %c specifier you used to read value for <n>
scanf( " %c", &n );
And use %d specifier rather than %c when you want to print calculation result.
printf( "%d", i + j );