Upload solution to Problem 2. Coded in C++