#include<stdio.h>
#include<string.h>
void main()
{
int n,i=0,j;
long int a[10];
printf("\n Enter decimal value=");
scanf("%d",&n);
while(n>0)
{
a[i]=n%16;
i++;
n=n/16;
}
printf("hexadecimal value=");
for(j=i;j>0;j--)
{
switch(a[j-1])
{
case 10: printf("\tA");
break;
case 11: printf("\tB");
break;
case 12: printf("\tC");
break;
case 13: printf("\tD");
break;
case 14: printf("\tE");
break;
case 15: printf("\tF");
break;
default: printf("\t %ld",a[j-1]);
}
}
}
#include<string.h>
void main()
{
int n,i=0,j;
long int a[10];
printf("\n Enter decimal value=");
scanf("%d",&n);
while(n>0)
{
a[i]=n%16;
i++;
n=n/16;
}
printf("hexadecimal value=");
for(j=i;j>0;j--)
{
switch(a[j-1])
{
case 10: printf("\tA");
break;
case 11: printf("\tB");
break;
case 12: printf("\tC");
break;
case 13: printf("\tD");
break;
case 14: printf("\tE");
break;
case 15: printf("\tF");
break;
default: printf("\t %ld",a[j-1]);
}
}
}
No comments:
Post a Comment