%d is used in printf() and scanf() when we know that the value is integer ( int).
%f is used in printf() and scanf() when we know that the value is real (float) .
%c is used in printf() and scanf() when we know that the value is charcter (char)
Why we use format specifiers ?
If we want to display some value stored in variable a how will we show it ?let us look at this program
#include<stdio.h>
#include<conio.h>
void main()
{
int a=10;
printf("hmm the value is a ");
getche();
}
the display will be
hmm the value is a
So to overcome this problem and display the real value stored in a ? here we use format specifier
as a is integer type (int) so we will use %d
in above code write this
printf("hmm the value is %d",a);
now run the program and you will fulfill you purpose of displaying the value stored in a
display will be hmm the value is 10