Which of the following gives the nth element of the Array?

2023

Which of the following gives the nth element of the Array?

  1. A.

    array[n];

  2. B.

    array[n-1];

  3. C.

    array[n+1];

  4. D.

    More than one of the above

  5. E.

    None of the above

Attempted by 1653 students.

Show answer & explanation

Correct answer: B

In most programming languages, arrays use 0-based indexing, meaning the first element is at index 0, the second at index 1, and so on. To access the nth element of an array, you need to use the index (n-1). For example, if n = 3, the third element is accessed using array[2]. Therefore, the correct expression is array[n-1].

Explore the full course: Up Lt Grade Assistant Teacher 2025