Coding exercises from chapter 3 of Computer Science: A Structured Approach Using C (Third Edition)