Solving Problems Using Array Functions Cpp