How to measure battery voltage from a microcontroller
If they were after the pseudo code then that was a bad question; it all depends on the microcontroller. I probably would have given the candidate the microcontroller's datasheet and observe how he works his way through that 300 pages document.  

Anyway, you connect the battery to an ADC input (assumptions: microcontroller has ADC on board and battery voltage is less than microcontroller supply voltage).


Set pin mode for that pin to ADC  
Select this ADC input if multiple ADC inputs  
Start ADC conversion  
Wait for end of conversion flag  
read ADC register  
calculate Vbat = Vcc x (ADC reading)/(2^ADC resolution)