The Format Specifier tells printf() where to put a value in a string and what format to use in printing the value.
Here are some of the format specifiers:
================================================
Here are some of the format specifiers:
================================================
Format printf() scanf()
================================================
single character %c %c
string %s %s
signed decimal integer %d %d
floating point %f %f or %e
unsigned decimal integer %u %u
unsigned hexadecimal integer %x %x
(ABCDEF...)
unsigned octal integer %o %o
Lets try format specifiers in our code:
#include<stdio.h>
#include<conio.h> //without this, you cannot use getch()
void main(void)
{
printf("My name is %s","Muzammil");
printf("I got %c grade in Intermediate",'A');
printf("I am %d years old",19);
getch();
}
Note: String should be in double quotes("string"), Single character should be in single quote('character') and integer & float should be used without any quotes.
If you have any kind of question....Goto 'Contact me' page.
0 comments:
Post a Comment