List of Format Specifiers in C – Name, Description, & Syntax | C Language

1
69
Format Specifiers list in C Language

Print the List of Format Specifiers with Specifiers Name, Description, & Syntax in C Language. Now the question is what are the Formate specifiers, types of formate specifiers.

In c programming language we need to tell the compiler about the data type what type of data is variable contains, formate specifiers, use to tell that during input and output operations?.

So basically use of formate specifiers is during scanf() and the printf() operations.

What are Format Specifiers

Formate specifiers tell the compiler that a variable data type, in simple words we can say that we have to provide a additions information to the compiler about the data type, which type of data is program contains while taking input and output.

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 of %f format specifier.

Syntax of Format Specifiers in C Language

  • scanf(“%lf”, &Variable_Name );
  • printf(“lf”, Variable_Name);

List of all Format Specifiers in C Programming Language

Name Description Syntax
%cSingle Characterscanf(“%c”, &Variable_Name );
%sStringsscanf(“%s”, &Variable_Name );
%hiShort(signed)scanf(“%hi”, &Variable_Name );
%hu Short(unsigned) scanf(“%hu”, &Variable_Name );
%l or %ld or %liSigned Integer(Signed Integer) scanf(“%l”, &Variable_Name );
%lfDoublescanf(“%lf”, &Variable_Name );
%LF Long Double scanf(“%LF”, &Variable_Name );
%luUnsigned integer scanf(“%lu”, &Variable_Name );
%lli or %lldSigned Integer(Long Long) scanf(“%lli”, &Variable_Name );
%lluUnsigned Integer(unsigned long long ) scanf(“%llu”, &Variable_Name );
%nPrints Nothing(No Output) printf(“%n”, Variable_Name );
%dDecimal Integer(Widly Used) scanf(“%d”, &Variable_Name );
%oOctal (Base 8) Integer scanf(“%o”, &Variable_Name );
%xHexadecimal (Base 16) Integer for Unsigned Integer scanf(“%x”, &Variable_Name );
%pAddress (Or Pointer) scanf(“%p”, &Variable_Name );
%fFloating Point Number for Floats scanf(“%f”, &Variable_Name );
%uInt Unsigned Decimal Integer scanf(“%u”, &Variable_Name );
%e or %EFloating Point Number in Scientific Notation(Float, Double) scanf(“%e”, &Variable_Name );
%% Prints % character printf(“%%”, Variable_Name );

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here