Capgemini interview question

Basic Technical question and small program to write