Wipro interview question

Ask me to write a code for the given scenario