#include <stdio.h> #include <stdint.h> void print_base(uint16_t num, uint8_t base) { // Your logic here if(num == 0) putchar('0'); int arr[20],i =0; while(num){ arr[i++] = num%base; num /= base; } for(int j=i-1;j>=0;j--){ if(arr[j] < 10) printf("%d",arr[j]); else printf("%c",'A' + (arr[j]-10)); } } int main() { uint16_t num; uint8_t base; scanf("%hu %hhu", &num, &base); print_base(num, base); return 0; }
Test Cases
Test Results
Input
10 2
Expected Output
1010