Question 34

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 = "Inheritance"; S +=6 ; cout<<S<< endl; }
  1. Aitence
  2. Btance
  3. CTence
  4. DInheri
Show answerHide answer

Correct answer: (B) tance

Explanation

S points to "Inheritance". S += 6 moves it to index 6 (I0 n1 h2 e3 r4 i5 t6), so cout prints "tance".

From DSSSB TGT Computer Science Practice Set 4

This is question 34 of DSSSB TGT Computer Science Practice Set 4. 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.