Program 4 for C++