#include<stdio.h> //Author : Khadiza Sultana void dectohex(int n){ if(n == 0) return; dectohex(n / 16); int rem = n % 16; if(rem < 10) printf("%d", rem); else printf("%c", rem - 10 + 'A'); } int main(){ printf("Enter a number : "); scanf("%d", &num); printf("Hexadecimal representation of %d : ", num); dectohex(num); printf("\n"); return 0; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter