Cognizant Interview Question

Basic programming and aptitude, logical.