Siemens interview question

Very basic C++ and algorithm question