why it is not taking any char input | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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

22nd Jan 2022, 4:10 PM
Harshit Mishra
Harshit Mishra - avatar
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 );
22nd Jan 2022, 4:30 PM
Ipang