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