#include <stdio.h> #include <stdint.h> void print_hex(uint16_t num) { char hex[] = "0123456789ABCDEF"; char value[4]; int i = 0; if(num == 0){ printf("%d",0); return; } while(num > 0){ value[i++] = hex[num % 16]; num/=16; } for (int j = i-1; j >= 0;j--){ putchar(value[j]); } } int main() { uint16_t num; scanf("%hu", &num); print_hex(num); return 0; }
Test Cases
Test Results
Input
255
Expected Output
FF