int main() { int num,rem,i=0,n; char answer[100]; printf("Enter a Decimal Number : "); scanf("%d",&num); n = num; while (num > 0) { rem = num % 16; if (rem < 10) { answer[i] = '0' + rem; } else { answer[i] = 'A' + (rem - 10); } num = num / 16; i++; }
printf("\nHexadecimal conversion of %d is :",n);
while (i--) { printf("%c",answer[i]); } printf("\n"); return 0; }
0 Comments