95.3k views
1 vote
Given the array declaration,

int a[20];
The last (legal) element is written as:
a) a[2]
b) a[0]
c) a[20]
d) a[19]

User CoffeJunky
by
6.6k points

1 Answer

5 votes

Final answer:

Given the array declaration, int a[20];The last (legal) element is written as:a[19].

The answer is option ⇒d) a[19]

Step-by-step explanation:

The correct answer for the last (legal) element of the array int a[20]; is a[19].

In C and C++ arrays are zero-based, which means that the first element is at index 0 and the last element is at index n-1, where n is the size of the array.

In the given declaration, int a[20];, we have an array named 'a' with a size of 20. Since the indexing starts from 0, the last element of the array will be at index 19.

The answer is option ⇒d) a[19]

User Jugal Shah
by
8.1k points