C code written during qualifying exam practice.