Print the List of Format Specifiers in C with Examples and also with Names, Descriptions, & Syntax in C Language. Now the question is what are the format specifiers, and what types of format specifiers In c programming language we need to tell the compiler about the data type what type of data is variable contains, formate specifiers, and use to tell that during input and output operations?
What Are Format Specifiers in C
Formate specifiers tell the compiler that a variable data type, in simple words we can say that we have to provide a piece of additional information to the compiler about the data type, and which type of data is program contains while taking input and output.
So basically use of formate specifiers is Used during scanf() and the printf() operations.
Format Specifiers
So the format specifiers define the data type or type of data. Below are some examples.
Examples: %c, %d, %f, and %lf etc.
What is %s and %d in C?
%s and %d are formate specifiers in C language, %s is used to take an input of string and print the string, String is a group of characters, and %d is used to take an integer as an input and output, %d is equal to the %i. Take a look at the %f format specifier.
Syntax of All Format Specifiers in C Language
- scanf(“%lf”, &Variable_Name );
- printf(“lf”, Variable_Name);
19 List of Format Specifiers in C with Examples
Name | Description | Syntax |
%c | Single Character | scanf(“%c”, &Variable_Name ); |
%s | Strings | scanf(“%s”, &Variable_Name ); |
%hi | Short(signed) | scanf(“%hi”, &Variable_Name ); |
%hu | Short(unsigned) | scanf(“%hu”, &Variable_Name ); |
%l or %ld or %li | Signed Integer(Signed Integer) | scanf(“%l”, &Variable_Name ); |
%lf | Double | scanf(“%lf”, &Variable_Name ); |
%LF | Long Double | scanf(“%LF”, &Variable_Name ); |
%lu | Unsigned integer | scanf(“%lu”, &Variable_Name ); |
%lli or %lld | Signed Integer(Long Long) | scanf(“%lli”, &Variable_Name ); |
%llu | Unsigned Integer(unsigned long long ) | scanf(“%llu”, &Variable_Name ); |
%n | Prints Nothing(No Output) | printf(“%n”, Variable_Name ); |
%d | Decimal Integer(Widely Used) | scanf(“%d”, &Variable_Name ); |
%o | Octal (Base 8) Integer | scanf(“%o”, &Variable_Name ); |
%x | Hexadecimal (Base 16) Integer for Unsigned Integer | scanf(“%x”, &Variable_Name ); |
%p | Address (Or Pointer) | scanf(“%p”, &Variable_Name ); |
%f | Floating Point Number for Floats | scanf(“%f”, &Variable_Name ); |
%u | Int Unsigned Decimal Integer | scanf(“%u”, &Variable_Name ); |
%e or %E | Floating Point Number in Scientific Notation(Float, Double) | scanf(“%e”, &Variable_Name ); |
%% | Prints % character | printf(“%%”, Variable_Name ); |
I hope you like the List of all Format Specifiers in C with Examples. Name, Description and Syntax. Below are some FAQs.
What is %s in C Programming?
%s is used to String, the syntax of %s is scanf(“%s”, &Variable_Name );
What is %lu in C?
%lu is used for unsigned integers and the syntax is scanf(“%lu”, &Variable_Name );
What is %d in C Called?
%d is widely used for Decimal Integer.
Format Specifier for String in C?
%s is used for string in C programming language.
Format Specifier for Short Int in C?
%hu is used for Short Int(Unsigned) and %hi is used for Short Int(Signed)
1 thought on “All 19 List of Format Specifiers in C with Examples- Updated”
Comments are closed.