Problem:
To convert the given decimal no into Hexadecimal without using in build function ,Example 26 shoule printed as 32
Solution:
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,intex[]={0,1,2,3,4,5,6,7,8,9,'A','B','C','D','E','F'},data[100],i=0,j;
clrscr();
printf("\n enter the no ..");
scanf("%d",&a);
printf("\nthe %d to binary is ",a);
while(a!=0)
{
data[i]=a%16;
i++;
a=a/16;
}
for(i--;i>=0;i--)
{
j=data[i];
if(j<=9)
printf("%d",intex[j]);
else
printf("%c",intex[j]);
}
getch();
}
Output:
To convert the given decimal no into Hexadecimal without using in build function ,Example 26 shoule printed as 32
Solution:
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,intex[]={0,1,2,3,4,5,6,7,8,9,'A','B','C','D','E','F'},data[100],i=0,j;
clrscr();
printf("\n enter the no ..");
scanf("%d",&a);
printf("\nthe %d to binary is ",a);
while(a!=0)
{
data[i]=a%16;
i++;
a=a/16;
}
for(i--;i>=0;i--)
{
j=data[i];
if(j<=9)
printf("%d",intex[j]);
else
printf("%c",intex[j]);
}
getch();
}
Output:
No comments:
Post a Comment