Computer Science, asked by rowan0709, 3 months ago

What is the value assigned to arr[2] in the following array initialization?
int arr[5] = {25,30,40,50,60};

Answers

Answered by anindyaadhikari13
2

Answer:

Given array,

>> arr[] = {25, 30, 40, 50, 60}

>> arr[2] = 40 (Answer)

Explanation:

Note that - Array index starts with 0 and ends with (array_length - 1).

Now, let us write the index of the given array elements.

\dag \:  \boxed{\begin{array} { c|c|c|c|c|c } \sf Element: & \sf 25 & \sf 30 & \sf 40 & \sf 50 & \sf 60 \\ \sf Index: & \sf 0 & \sf 1 & \sf 2 & \sf 3 & \sf 4\end{array}}

→ From the figure, we can see that the element at index 2 is 40.

→ Therefore, 40 is stored in index 2 of the given array.

Learn More:

  • Array: An array is a variable which can store more than one value at a specific time. It stores values of particular data type.
  • There are two types of arrays - Static array and Dynamic array.
Similar questions