Capgemini Invent Interview Question

simple programs and it's output