Tata interview question

Basic programming