LG Electronics interview question

Finding output of program