The printf() function and Format specifier
For showing any type variable values with the printf() function, we need to use the formate specifier of the variable. In C, after the persent(%) sign use a character for making the formate specifier. Formate specifier use in the double quation (“”) in the printf() function.
As example :
#include<stdio.h> void main() { int a; a=10; print f(“%d The value of a is : ”,a); } output: The value of a is : 10 |
Observe the example program, we use the format specifier “%d” for the integer type variable a and the output is showing the value of a.
Now here is a list of formate specifier :
formate specifier | use |
%d | display the integer value display |
%f | display the floating point number |
%c | display the single charecter |
%s | display the chatecter string |
Written by “Shojib”
No comments:
Post a Comment