c code exercise reference from LcodeTHW