In C programming, the format specifier %d is used to handle integer numbers in functions such as printf and scanf.
An integer value is printed using ‘printf’: %d. It instructs printf to print the argument as a signed decimal integer and to anticipate an input of type int.
int number = 25;
printf(“The number is %d\n”, number);
Output:
The number is 42.
To read an integer value from user input, use scanf: %d. It instructs scanf to store the outcome in a variable of type int and to anticipate input in the form of a signed decimal integer.
int number;
printf(“Enter the number”);
scanf(“%d”, &num);
printf(“You entered “%d\n”, number);
Output:
You entered 42.