Wipro interview question

PROGRAMMING ABILITY (ONLY LOGIC)