Format specifiers in C | format specifiers in c with examples

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

Format Specifiers ko ham input and output ke time use karte hai.inke kuch example aap niche dekh sakte hai.

Some Example :-

Format specifiers list

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 |

Summary
Review Date
Reviewed Item
Format specifiers in C
Author Rating
51star1star1star1star1star

Danish Ali

I Am a 1st Sem BCA Student & I have Skills C, C++ ,Python, HTML,CSS, Computer & Advance Hacking & Blogger & YouTuber.

2 thoughts on “Format specifiers in C | format specifiers in c with examples

Leave a Reply

Your email address will not be published. Required fields are marked *

error

Enjoy this blog? Please spread the word :)