Write to program in C to change hexadecimal to decimal and octal.

Write to program in C to change hexadecimal to decimal and octal.

Write to program in C to change hexadecimal to decimal and octal.

/*
Author : Sabya Roy
*/

 

#include<stdio.h>
#include<conio.h>
main()
{
          int n;                                                                      //Initialization of variable
          printf(“Enter a hexadecimal number : “);
          scanf(“%x”, &n);                                                 //’%x’ to input hexadecimal
          printf(“The decimal format is : %i.”, n);       //display output in decimal
          printf(“\nThe octal format is : %o.”, n);       //display output in octal
          getch();
}

———————————————————————————————————————————————————-




Output :

Enter a hexadecimal number : a2b
The decimal format is : 2603
The octal format is : 5053

———————————————————————————————————————————————————-

Share this post

Leave a Reply

Your email address will not be published. Required fields are marked *