Showing posts with label Convert Decimal to Hexadecimal Number. Show all posts
Showing posts with label Convert Decimal to Hexadecimal Number. Show all posts

Convert Decimal to Hexadecimal Number


#include<stdio.h>
#include<conio.h>
#include<process.h>
void main()
{
Int x, y=30, z;
clrscr();
printf(“Enter the number:);
scanf(%d”, &x);
printf(“\n conversion of decimal to hexadecimal number\n”);
for(;;)
{
if(x= =0)
exit(1);
z=x%16;
x=x/16;
gotoxy(y--,5);
switch(z)
{
Case 10:
Printf(“A”);
Break;
Case 11:
Printf(%c”, „B?);
Break;
Case 12:
Printf(%c”, „C”);
Break;
Case 13:
Printf(“D”);
Break;
Case 14:
Printf(“E”);
Break;
Case 15:
Printf(“F”);
Default:
Printf(%d”, z);
}
}
getch();
}

Output:
Enter the number: 31
Conversion of decimal to Hexa decimal number
1F

Labels