Format specifiers in C :- format specifiers kiya hota hai or format specifier for binary in c iska kese use hota hai ham is post me example ke sath format specifier in c in hindi understand karte hai.
Format specifiers in C
Contents
- 1 Format specifiers in C
- 1.0.1 format specifier for binary in c
- 1.0.2 Character format specifier : %c
- 1.0.3 C Programming | Full Course C programming language
- 1.0.4 Unsigned Hexadecimal for integer : %x, %X
- 1.0.5 String printing : %s
- 1.0.6 decimal integer : %d
- 1.0.7 Floating data type : %f, %e(double), %lf(long double)
- 1.0.8 String data type
- 1.1 Share this:
Format Specifiers ko ham input and output ke time use karte hai.inke kuch example aap niche dekh sakte hai.
Some Example :-

format specifier for binary in c
Format Specifier ko ek ek karke alg alg example ko dekhte hai .
Character format specifier : %c
#include <stdio.h>
int main()
{
char ch = 'A';
printf("%c\n", ch);
return 0;
}
Output :-
A
basic data types in c |data types in c with examples
Integer format specifier : %d, %i
#include <stdio.h>
int main()
{
int x = 45, y = 90;
printf("%d\n", x);
printf("%i\n", x);
return 0;
}
output :-
45
45
Double format specifier : %f, %e or %E
#include <stdio.h>
int main()
{
float a = 12.67;
printf("%f\n", a);
printf("%e\n", a);
return 0;
}
output :-
12.670000
1.267000e+01
C Programming | Full Course C programming language
Unsigned Octal number for integer : %o
#include <stdio.h>
int main()
{
int a = 67;
printf("%o\n", a);
return 0;
}
Output :-
103
Unsigned Hexadecimal for integer : %x, %X
#include <stdio.h>
int main()
{
int a = 15;
printf("%x\n", a);
return 0;
}
Output :-
f
String printing : %s
#include <stdio.h>
int main()
{
char a[] = "Masterprograming.com";
printf("%s\n", a);
return 0;
}
Output :-
Masterprograming.com
More formatting
#include <stdio.h>
int main()
{
char str[] = "masterprograming.com";
printf("%20s\n", str);
printf("%-20s\n", str);
printf("%20.5s\n", str);
printf("%-20.5s\n", str);
return 0;
}
Output :-
masterprograming.com
masterprograming.com
maste
maste
decimal integer : %d
#include <stdio.h>
int main()
{
int a = 0;
scanf("%d", &a); // input is 45
printf("%d\n", a);
return 0;
}
output :-
45
Floating data type : %f, %e(double), %lf(long double)
#include <stdio.h>
int main()
{
float a = 0.0;
scanf("%f", &a); // input is 45.65
printf("%f\n", a);
return 0;
}
Output :-
0.000000
String data type
#include <stdio.h>
int main()
{
char str[20];
printf("Enter Your Name : ");
scanf("%s", str); // input is masterprograming
printf("%s\n", str);
return 0;
}
Output :-
Enter Your Name : masterprograming
masterprograming
Dosto mujhe ummed hai ki aap ‘format specifiers in c with examples’ ko acchi tarah se samanj gye honge agar aap ko ye post acchi lage to mere is website ko jarur follow kre or ha agar aap video bhi dekhna chahte hai to aap mere channel ko bhi subscribe kar sakte hai. channel ka link aapko home page par mil jayega |