%d and %i

[ad_1]

[0]
Format Specifier
The format specifier
which means values should be decimal whether it is negative or positive.

Format Specifier
The format specifier
values should be decimal, octal and hexadecimal and octal value is provided by
preceding ‘0’ while hexadecimal value is provided by preceding ‘0x’.

[1]
They are the same when used for output, e.g. with printf.

However, these are different when used as input specifier e.g. with scanf,
where
decimal but also allows hexadecimal (if preceded by 0x) and octal (if preceded
by 0).

So 033 would be 27 with

[2]
These are identical for printf but different for scanf. For printf, both
and
signed integer but
by 0x and octal if preceded by 0 and otherwise interprets the input as
decimal.
�

There is no difference between the

�

behaves differently while they are used with an input specifier. So, 012 would
be 10 with

along with positive values but values should be in decimal otherwise it will
print garbage value.( Note: if input is in octal format like:012 then
ignore 0 and take input as 12)


To enter a value in hexadecimal format – value should be provided by preceding
“0x” and value in octal format – value should be provided by preceding “0”. 

[ad_2]

Please follow and like us:
error
fb-share-icon