Cognizant interview question

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