Tech Mahindra Interview Question

C++ basics ,sql queries and a puzzle