Data Device interview question

Algorithm to solve simple programming questions (if, else statement).