/*WAP to find hexadecimal conversion
of a given deimal number*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
long int n,i=0,k,j,s[16];
clrscr();
printf("Enter any Decimal Number:");
scanf("%ld",&n);
printf("\nHexadecimal\n");
printf("\n\n%x\n\n",n);
while(n!=0)
{
s[i]=n%16;
printf("%d:::",s[i]);
n=n/16;
printf("%d...",n);
i++;
}
printf("\nHexadecimal Conversion:");
for(j=i-1;j>=0;j--)
{
if(s[j]<=9)
printf("%ld",s[j]);
else if(s[j]==10)
printf("A");
else if(s[j]==11)
printf("B");
else if(s[j]==12)
printf("C");
else if(s[j]==13)
printf("D");
else if(s[j]==14)
printf("E");
else if(s[j]==15)
printf("F");
}
getch();
}
No comments:
Post a Comment