ex2.cpp finalized.