In firmware development, you might need to convert numbers to binary or hexadecimal strings manually — for instance, sending over UART or displaying on an LCD — without using standard library functions like itoa().
Your task is to:
- Read an unsigned integer num and a base (2 or 16)
- Print the number in the given base as a string
- You must not use any standard string conversion like itoa() or sprintf()
- Use only loops and arithmetic
Example-1
Input: num = 10, base = 2
Output: 1010
Example-2
Input: num = 255, base = 16
Output: FF
Example-3
Input: num = 0, base = 2
Output: 0