Question 10Asked in DSSSB TGT Computer Science (Technical), 1 Aug 2021, Shift 1

What is the length of an array when its first index is denoted by i and last index is denoted by j?

  1. ALength of an array = i + j
  2. BLength of an array = j − i
  3. CLength of an array = j − i + 1
  4. DLength of an array = j − i − 1
Show answerHide answer

Correct answer: (C) Length of an array = j − i + 1

Explanation

Indices i, i+1, ..., j contain j − i + 1 elements. For example, indices 0 to 9 give 10 elements.

From DSSSB TGT Computer Science PYQ (Technical), 1 Aug 2021, Shift 1

This is question 10 of DSSSB TGT Computer Science PYQ (Technical), 1 Aug 2021, Shift 1. 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.