#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
long int decimal_num, quotient;
char hexa_decimal_num[100];
int i=1, j, temp;
printf("\n Enter any decimal number : ");
scanf("%ld",&decimal_num);
quotient=decimal_num;
while(quotient!=0)
{
temp=quotient%16;
// to convert integer into character
if(temp<10)
{
temp=temp+48;
}
else
{
temp=temp+55;
}
hexa_decimal_num[i++]=temp;
quotient=quotient/16;
}
printf("\n Equivalent hexadecimal value of %d is : \n",decimal_num);
for(j=i-1; j>0; j--)
{
printf("\t %c",hexa_decimal_num[j]);
}
getch();
}
Run1:
Run2:
Previous Next
#include<conio.h>
void main()
{
clrscr();
long int decimal_num, quotient;
char hexa_decimal_num[100];
int i=1, j, temp;
printf("\n Enter any decimal number : ");
scanf("%ld",&decimal_num);
quotient=decimal_num;
while(quotient!=0)
{
temp=quotient%16;
// to convert integer into character
if(temp<10)
{
temp=temp+48;
}
else
{
temp=temp+55;
}
hexa_decimal_num[i++]=temp;
quotient=quotient/16;
}
printf("\n Equivalent hexadecimal value of %d is : \n",decimal_num);
for(j=i-1; j>0; j--)
{
printf("\t %c",hexa_decimal_num[j]);
}
getch();
}
Run1:
Run2:
Previous Next
No comments:
Post a Comment