Cognizant Interview Question

Was asked to actually write whole code with acurate syntaxes in C++