English

The index (subscript) of the last element of an array ar[ ] is ______. - Computer Applications

Advertisements
Advertisements

Question

The index (subscript) of the last element of an array ar[ ] is ______.

Options

  • ar.length( )

  • ar[ ].length

  • ar.length()-1

  • ar.length-1

MCQ
Fill in the Blanks
Advertisements

Solution

The index (subscript) of the last element of an array ar[ ] is ar.length-1.

Explanation:

ar.length gives the last position, and -1 gives the actual index, as the index of the array starts from 0 to n-1.

shaalaa.com
  Is there an error in this question or solution?
2024-2025 (March) Official Board
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×