Question 77

Select the correct output of the following C++ program segment assuming all necessary header files are correctly included:

Select the correct output of the following C++ program segment assuming all necessary header files are correctly included: void main( ) { char *S = "MySQL"; S += 2; cout << S <<endl; }
  1. ASQL
  2. BQL
  3. CMy
  4. DMyS
Show answerHide answer

Correct answer: (A) SQL

Explanation

S points to "MySQL". S += 2 moves it past 'M' and 'y' to 'S', so cout prints the string from there: SQL.

From DSSSB TGT Computer Science Practice Set 5

This is question 77 of DSSSB TGT Computer Science Practice Set 5. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.