0% found this document useful (0 votes)
60 views8 pages

List of Format Specifiers in C

Format Specifiers

Uploaded by

Vilasini Rajesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views8 pages

List of Format Specifiers in C

Format Specifiers

Uploaded by

Vilasini Rajesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

List of Format Specifiers in C

The below table contains the most commonly used format specifiers in C
Format Specifier Description

%c For character type.

%d For signed integer type.

%e or %E For scientific notation of floats.

%f For float type.

%g or %G For float type with the current precision.

%i Unsigned integer

%ld or %li Long

%lf Double

%Lf Long double

%lu Unsigned int or unsigned long

%lli or %lld Long long

%llu Unsigned long long

%o Octal representation

%p Pointer

%s String

%u Unsigned int

%x or %X Hexadecimal representation
Format Specifier Description

%n Prints nothing

%% Prints % character
The data types in C can be classified as follows:
Types Description

Primitive data types are the most basic data types that are
Primitive Data
used for representing simple values such as integers, float,
Types
characters, etc.

The data types that are derived from the primitive or built-in
Derived Types
datatypes are referred to as Derived Data Types.

User Defined
The user-defined data types are defined by the user himself.
Data Types
Size Format
Data Type (bytes) Range Specifier

short int 2 -32,768 to 32,767 %hd

unsigned
2 0 to 65,535 %hu
short int

unsigned int 4 0 to 4,294,967,295 %u

-2,147,483,648 to
int 4 %d
2,147,483,647

-2,147,483,648 to
long int 4 %ld
2,147,483,647

unsigned long
4 0 to 4,294,967,295 %lu
int

long long int 8 -(2^63) to (2^63)-1 %lld

unsigned long 0 to
8 %llu
long int 18,446,744,073,709,551,615

signed char 1 -128 to 127 %c

unsigned
1 0 to 255 %c
char
Size Format
Data Type (bytes) Range Specifier

float 4 %f
1.2E-38 to 3.4E+38

double 8 %lf
1.7E-308 to 1.7E+308

long double 16 %Lf


3.4E-4932 to 1.1E+4932
Operator Precedence and Associativity Table
The following tables list the C operator precedence from highest to lowest and
the associativity for each of the operators:

Operator
Precedence Description Associativity

Parentheses
()
(function call)

Array Subscript
[]
(Square Brackets)

1 . Dot Operator Left-to-Right

Structure Pointer
->
Operator

Postfix increment,
++ , —
decrement

Prefix increment,
++ / —
decrement

+/– Unary plus, minus

Logical NOT,
!,~
Bitwise complement

2 (type) Cast Operator Right-to-Left

Dereference
*
Operator

& Addressof Operator

Determine size in
sizeof
bytes
Operator
Precedence Description Associativity

Multiplication,
3 *,/,% Left-to-Right
division, modulus

4 +/- Addition, subtraction Left-to-Right

Bitwise shift left,


5 << , >> Left-to-Right
Bitwise shift right

Relational less than,


< , <=
less than or equal to
6 Left-to-Right
Relational greater
> , >= than, greater than or
equal to

Relational is equal
7 == , != Left-to-Right
to, is not equal to

8 & Bitwise AND Left-to-Right

Bitwise exclusive
9 ^ Left-to-Right
OR

10 | Bitwise inclusive OR Left-to-Right

11 && Logical AND Left-to-Right

12 || Logical OR Left-to-Right

13 ?: Ternary conditional Right-to-Left

14 = Assignment Right-to-Left

+= , -= Addition, subtraction
Operator
Precedence Description Associativity

assignment

Multiplication,
*= , /=
division assignment

Modulus, bitwise
%= , &=
AND assignment

Bitwise exclusive,
^= , |= inclusive OR
assignment

Bitwise shift left,


<<=, >>=
right assignment

comma (expression
15 , Left-to-Right
separator)

You might also like