In C language, the format specifiers %i and %d have subtle differences. %i can specify integers with decimal, hexadecimal or octal type values, while %d specifies signed decimal integers with negative or positive values. When used with the output function Printf (for writing format), there is no difference between %i and %d.
However, when used with the Scanf (for reading input) %i automatically detects the base integer where %d assumes the integer base is base 10. So, to enter a value using %i in hexadecimal format, the value needs to be preceded using “0x” and in octal format, the value needs to be preceded by “0”.