Cognizant interview question

Coding basics