Format Specifier %d
The format specifier %d takes integer value as a signed decimal integer value which means values should be decimal whether it is negative or positive.
Here is an example of format specifier %d in C language,
Example
#include <stdio.h>int main() {
int v1 = 7456;
int v2 = -17346;
printf("The value in decimal form : %d\n", v1);
printf("The value in negative : %d", v2);
return 0;
}
OutputThe value in decimal form : 7456The value in negative : -17346
Format Specifier %iThe format specifier %i takes integer value as an integer value which means values should be decimal, octal and hexadecimal and octal value is provided by preceding ‘0’ while hexadecimal value is provided by preceding ‘0x’.
Here is an example of format specifier %i in C language,
#include <stdio.h>int main() {
int v1 = 1327;
int v2 = 0x42451;
printf("The value in decimal form : %d\n", v1);
printf("The value in hexadecimal form : %i", v2);
return 0;
}
OutputThe value in decimal form : 1327The value in hexadecimal form : 271441