Infosys interview question

Basic question on CPP,SQL and interviewer asked me to write the code.