Infosys interview question

Interviewer asked basic coding questions