0% found this document useful (0 votes)
50 views2 pages

C Language #03: Some Often-Used Format Specifiers For Printf

This document provides a summary of common format specifiers for printf() and scanf() in C language. For printf(), specifiers like %d print decimal integers, %c prints single characters, and %s prints strings. For scanf(), specifiers like %c read single characters, %d reads decimal integers, and %s reads strings. The format specifiers allow printing and reading different data types in a standardized way.

Uploaded by

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

C Language #03: Some Often-Used Format Specifiers For Printf

This document provides a summary of common format specifiers for printf() and scanf() in C language. For printf(), specifiers like %d print decimal integers, %c prints single characters, and %s prints strings. For scanf(), specifiers like %c read single characters, %d reads decimal integers, and %s reads strings. The format specifiers allow printing and reading different data types in a standardized way.

Uploaded by

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

C LANGUAGE #03

some often-used format specifiers


for printf()
Used for Used for
Format Format
specifier specifier
Print a decimal integer To print a unsigned decimal integer
%d %u
Print a single character Print a unsigned octal decimal
%c %o integer
Print a string Print a unsigned hexadecimal integer
%s %x using a,b,c,d,e,f
Print a floating-point Print a floating point number in
%f number %e exponential format
Print a pointer in To print %
%p hexadecimal format %%

For scanf()

Used for
Used for
Format Format
specifier specifier
Read a single character Read an unsigned hexadecimal
%c %x,%X integer
Read a signed decimal Read a floating-point number
%d integer %e,%E
Read a signed integer, base is decided Read a floating-point number
%i by prefix of the input
number,0x→hexadecimal,0→octal,
%g,%G
otherwise read a signed decimal integer
Read a unsigned decimal Read a string
%u integer %s
Read a unsigned octal Read a floating-point number
%o integer %f

You might also like