Siemens interview question

Coding question C++