Cognizant interview question

Basic questions from programming and probability.