Added the source code which apparently came with the book. Found it on github somewhere.
looks like I got my answer for Ex5-2 which is weird though and unexpected.
Looks like solved Ex4-1