Infosys interview question

During the coding questions, asked some modifications and rewrite the code.