Users Online

· Guests Online: 131

· Members Online: 0

· Total Members: 188
· Newest Member: meenachowdary055

Forum Threads

Newest Threads
No Threads created
Hottest Threads
No Threads created

Latest Articles

14 C program to Convert Decimal to Hexadecimal

This C Program Converts the given Decimal to Hexadecimal. Decimal is a term that describes the base-10 number system commonly used by lay people in the developed world. Hexadecimal is base 16 arithmetic where each digit is a value from 0 to 15, rather than the 0-9 of base 10.
Here is source code of the C program to Convert Decimal to Hexadecimal. The C program is successfully compiled and run on a Linux system. The program output is also shown below.

/*
* C program to Convert Decimal to Hexadecimal
*/
#include <stdio.h>

int main()
{
long decimalnum, remainder, quotient;
int i = 1, j, temp;
char hexadecimalnum[100];

printf("Enter decimal number: ");
scanf("%ld", &decimalnum);

quotient = decimalnum;

while (quotient != 0)
{
temp = quotient % 16;
// To convert integer into character
if (temp 0; j--)
printf("%c", hexadecimalnum[j]);
return 0;
}

Output:
$ cc pgm1.c
$ a.out
Enter decimal number: 12
Equivalent hexadecimal value of 12 : C

Comments

No Comments have been Posted.

Post Comment

Please Login to Post a Comment.

Ratings

Rating is available to Members only.

Please login or register to vote.

No Ratings have been Posted.
Render time: 1.03 seconds
10,813,888 unique visits