Cognizant interview question

SQL queries, Pattern printing and reverse the string