C Program to convert decimal number to hexadecimal - c programs
//C Program to convert decimal number to hexadecimal
//decimal number to hexadecimal conversion in / using c
#include <stdio.h>
void main()
{
int i=0,n,b[100];
printf("\n For Decimal to Hexadecimal converstion");
printf("\nEnter decimal number: ";
scanf("%d",&n);
while (n>0)
{
b[i]=n%16;
n=n/16;
i++;
}
printf("\n Hexadecimal is: ");
while(i>0)
{
if (b[i]<10)
{
printf(b[i]);
]
else
{
switch(b[i])
{
case 10:
printf("A");
break;
case 11:
printf("B");
break;
case 12:
printf("C");
break;
case 13:
printf("D");
break;
case 14:
printf("E");
break;
case 15:
printf("F");
break;
}
}
}
}
}
//decimal number to hexadecimal conversion in / using c
#include <stdio.h>
void main()
{
int i=0,n,b[100];
printf("\n For Decimal to Hexadecimal converstion");
printf("\nEnter decimal number: ";
scanf("%d",&n);
while (n>0)
{
b[i]=n%16;
n=n/16;
i++;
}
printf("\n Hexadecimal is: ");
while(i>0)
{
if (b[i]<10)
{
printf(b[i]);
]
else
{
switch(b[i])
{
case 10:
printf("A");
break;
case 11:
printf("B");
break;
case 12:
printf("C");
break;
case 13:
printf("D");
break;
case 14:
printf("E");
break;
case 15:
printf("F");
break;
}
}
}
}
}
No comments:
Post a Comment