Capgemini Interview Question

In pseudocode based on the output questions