174k views
5 votes
Assume that the array arr has been declared. In addition, assume that ARR_SIZE has been defined to be an integer that equals the number of elements in arr. Write a statement that assigns to x the value of the next to last element of the array (x has already been declared).

1 Answer

1 vote

Answer:

x = arr[ARR_SIZE-2];

Step-by-step explanation:

As array is arr has been declared:

int arr[6] = {0,1,2,3,4,5}; " ARR_SIZE=6"

As x is an integer then

x = arr [ARR_SIZE-2];

It means working will be

x= arr[6-2];

x=arr[4]; at index 4 we get

=4

User ASHWIN RAJEEV
by
8.0k points