C Program to Convert Decimal number to Hexa Decimal  Number

C Program to Convert Decimal number into Hexa Decimal Number

This page has a C Program to Convert Decimal number to Hexa Decimal Number. It is clear that, this C program will Convert the given Decimal number into Hexa Decimal Number. To convert decimal number into Hexa Decimal number, the program should divide the decimal number by 16 again and again till the number can be divided by 16 and the program should display (print) the remainders for each division on monitor screen (in reverse order) to form the Hexa Decimal equivalent. For Example: If the Decimal number 39 is given as input, the program will print the Hexa Decimal equivalent as 27.  The below given C program is used to Convert the given Decimal number into Hexa Decimal NumberKindly check out the program to Convert the given Decimal number into Hexa Decimal NumberThe Questions to Convert Decimal number into Hexa Decimal Number problem can be asked as . .

1). C Program to Convert Decimal number to Hexa Decimal Number.   

2). C Program to Convert the given Decimal number into Hexa Decimal Number  

3). C Program to find the Hexa Decimal equivalent of given Decimal number.

4). C Program to Print Hexa Decimal Equivalent of a Decimal Integer   

5). Program to convert decimal to Hexa Decimal in c

Decimal number to Hexa Decimal 

Number Program


   #include<stdio.h>
   #include<conio.h>
   void decimal_to_hexa(long int);
   int main(){
                 long int decimal;
                 clrscr();
                 printf("Enter an Integer decimal number : ");
                 scanf("%ld", &decimal);
                 printf("\n\n The given decimal number is : %ld", decimal);
                 decimal_to_hexa(decimal);
                 getch();
   return(0);
   }
   void decimal_to_hexa(long int n){
                long int a=1, i, remain[40];
                printf("\n\n The Hexa Decimal number is : ");
                while(n>0){
                remain[a] = n % 16;
                n = n / 16;
                a++;
                }
                a--;
                for(i=a;i>=1;i--){
                if(remain[i]==10)
                printf("A");
                else
                if(remain[i]==11)
                printf("B");
                else
                if(remain[i]==12)
                printf("C");
                else
                if(remain[i]==13)
                printf("D");
                else
                if(remain[i]==14)
                printf("E");
                else
                if(remain[i]==15)
                printf("F");
                else
                printf("%ld", remain[i]);
                }
   }


Sample Output:

Enter an Integer decimal number : 45

The given decimal number is : 45


 The Hexa Decimal number is : 2D

Related Other Popular C Programs

*  Write a c program to check whether a given number is prime number or not?

 

*  Write a C program to find the prime numbers between 1 and 100

 

*  Write a C program to display the prime numbers between a range ?

 

*  Write a C program to find the prime numbers between a range using while loop?

 

*  Write a C program to find the sum of prime numbers between a range 

About Er. T.Tharesh Kumar

I am a Professor and Head of Department of Computer Science in an Arts and Science College. I have designed this website to provide solved example programs of different categories for all the school and college going students to learn C language deeply, and to practice Interview based Multiple Choice (Objective Type) questions and answers.

Other Related C Programs :


* C Program to find whether the given number is Odd or Even

* C Program to find the Sum of Odd Digits

* C Program to find the Sum of Even Digits

* C Program to find the Sum of Even and Odd Digits,

* C Program to Display Odd digits

* C Program to Display even digits

* C Program to Display Odd Numbers,

* C Program to Display Even Numbers,

* C Program to Check whether the given number is Armstrong number

* C Program to display the Armstrong numbers in Range

* C Program to display the Armstrong numbers between 1 and 1000

* C Program to check perfect number, perfect numbers in range

* C Program to Check Prime number, Prime numbers between 1 and 100

* C Program to display the Prime numbers in a Range

* C Program to display the Sum of Prime numbers

* C Program to Check Strong number

* C Program to display the Strong number in Range

* C Program to Check whether the given number is polindrome number or not

* C Program to Check polindrome number using for loop

* C Program to Check polindrome number using Recursion

* C Program to  check whether the given string is polindrome or not

* C Program to find the Roots of Quadratic equation

* C Program to display Fibonacci Series

* C Program to display the Fibonacci Series using an array

* C Program to display the Fibonacci Series using while loop

* C Program to find the Sum of Fibonacci Series, Factorial of Number

* C Program to find the Factorial without using Recursion

* C Program to find the Factorial using Pointers

* C Program to find the Factorial using Function

Bookmark and Share