0

Why op skip after i enter first num.

int num[100],rt; char op; printf("Enter number:\n"); scanf("%d",&num[0]); printf("Enter operator:\n"); scanf("%c",&op); printf("Enter number:\n"); scanf("%d",&num[1]);

22nd Jun 2017, 7:28 AM
Frankestine Stine
Frankestine Stine - avatar
3 Respuestas
+ 1
here in the example the first no is int that is of 2 bite and second input is of 1 byte. thats why compiler dosent take it as input . so solution to this is use fflush (stdin );after scanf function.
22nd Jun 2017, 7:39 AM
Rohan Vijayvergiya
Rohan Vijayvergiya - avatar
0
can you explain function of fflush(stdin);
22nd Jun 2017, 7:48 AM
Frankestine Stine
Frankestine Stine - avatar
0
it simply clears the input buffer,its like clrscr () but it works for input values but not a single value is manipulated.
22nd Jun 2017, 7:50 AM
Rohan Vijayvergiya
Rohan Vijayvergiya - avatar