RedPlanet Berhad interview question

Few programming logic questions need to be answered