Capgemini Invent interview question

simple programs and it's output