Intel Corporation Interview Question

two logic questions and one programing question.