American Express interview question

Output of a program