Difference between %d and %i || Basic Program || C programming
In this, we are going to see a basic program for Difference between %d and %i in C Programming Language.

 

#include<stdio.h>

int main()
{
    int dec, oct, hex;

    printf("Enter value in decimal format :");
    scanf("%d", &dec);

    printf("Enter value in octal format : ");
    scanf("%i", &oct);

    printf("Enter value in hexadecimal format : ");
    scanf("%i", &hex);

    /*%d considers the base as 10 but %i auto-detects the base when used*/
    printf("dec = %i, oct = %i, hex = %i", dec, oct, hex);

    return 0;
}

//..........Coded by RISHAB NAIR

#ENJOY CODING

Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post