homework2 of coursera "cpp2cprogrammers"