Add ex3.c from chapter 4