Data Type in C


data type

type size [bytes]size [bits]mininummax
(signed) (short) int216-32768+32767
(signed) long int 432-21474836482147483647
unsigned (short) int216065535
unsigned long int 43204294967295
(unsigned) char 180255
signed char 18-128+127
float 432
double 864
long double 16128

Format of printf and scanf

printf(const char *formatp, ...)
scanf(const char *formats, ...)
formatp = '%' + FLAG + FIELDWIDTH + SPECIFIER
formats = '%' + FIELDWIDTH + SPECIFIER


Flag

FLAGOUTPUT
0fill zero
-left align
+print + or - before number
(space)print space before number
#print radix

Conversion Specifier

SPECIFIEROUTPUTINPUT
ddecimal integerint
hddecimal integer(short) int
lddecimal integerlong int
udecimal integerunsigned int
hudecimal integerunsigned (short) int
ludecimal integerunsigned long int
ooctadecimal integerunsigned int
hooctadecimal integerunsigned (short) int
looctadecimal integerunsigned long int
x, Xhexadecimal integerunsigned int
hx, hXhexadecimal integerunsigned (short) int
lx, lXhexadecimal integerunsigned (long) int
fdouble (xxx.xxx)float
e, Efloat (xxx.xxxe+xx)float
G, G(double or float
automatically selected)
float
le, lE, lf, lg, lG(see f,e)double
Le, LE, Lf, Lg, LG(see f,e)long double