Siemens Interview Question

Coding question C++