Home / Programs / Integer format specifier : %d, %i Example program
Programming Example

Integer format specifier : %d, %i Example program

👁 1,018 Views
💻 Practical Program
📘 Step by Step Learning
Integer format specifier : %d, %i

Program Code

#include <stdio.h> 
int main() 
{ 
    int x = 45, y = 90; 
    printf("%d\n", x); 
    printf("%i\n", x); 
    return 0; 
} 

Output

45
45

Explanation

Integer Format Specifier %d

The %d format specifier is implemented for representing integer values. This is used with printf() function for printing the integer value stored in the variable.

Syntax:
printf("%d",<variable name>);

 

How to learn from this program

First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.