I need the answer to the questions in both documents. The codes must be in C++.

I need the answer to the questions in both documents. The codes must be in C++. As much as possible please use basic C++ code and syntax. Thank you in advance!