LG Electronics Interview Question

Finding output of program