#include <stdio.h> #include <stdint.h> void print_hex(uint16_t num) { // Your logic here char hex[16]; int i = 0; if(num == 0){ printf("0"); return; } while(num > 0){ int rem = num % 16; if(rem < 10){ hex[i++] = rem + '0'; } else { hex[i++] = rem - 10 + 'A'; } num = num / 16; } for(int j = i - 1; j >= 0; j--){ printf("%c", hex[j]); } } int main() { uint16_t num; scanf("%hu", &num); print_hex(num); return 0; }
Test Cases
Test Results
Input
255
Expected Output
FF