Pergunta de entrevista da empresa IBM

Coding question in C++ and one SQL query