Solve problem 44 using C++.