•%d and %i behave similar with printf
There is no difference between the %i and %d format specifiers for printf.
•%d and %i behavior is different in scanf
%d assume base 10 while %i auto detects the base. Therefore, both specifiers
behaves differently while they are used with an input specifier. So, 012 would
be 10 with %i but 12 with %d.
%d takes integer value as signed decimal integer i.e. it takes negative values
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 %d will
ignore 0 and take input as 12)
%i takes integer value as integer value with decimal, hexadecimal or octal type.
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”.