changed ex14.cpp exercise code