Nokia interview question

problem solving in c and c++.