Qualcomm interview question

Some coding question in C++