Microchip Technology Interview Question

they asked me to code a simple c utility function.