complete ex. 4 c++