2(viii)
Consider the following array and answer the questions given below:
int a[] = {12, 10, 8, 4, 6, 2, 3, 5, 7};
(a) What is the output of System.out.print(a[0] + a[5]);?
(b) What is the index (subscript) of the largest element of the array a[]?
Show SolutionHide Solution↓
(a) 14
(b) The largest element in the array is 12, which is at index 0.
- a[0] is 12.
- a[5] is 2.
- Sum = 12 + 2 = 14.