I am teaching C language basic program and there is this point that I have noticed.
#include<stdio.h>
#include<conio.h>
void main(){
int a;
float b;
char c;
printf("Enter a number");
scanf("%d",&a);
printf("\nEnter a Float");
scanf("%f",&b);
printf("\nEnter a character");
scanf("%c",&c);
printf("Number is %d",a);
printf("Float Number is %f",b);
printf("Character is %c",c);
}
When running this simple code, I am able to enter value of int and float but then the program just runs without letting me insert the value of character. Now I know the solution is to put the character scanf function first but what I do not get it why is it happening?