Pregunta de entrevista de Experian

Giving the problem with applied pattern solve them using if else statement.