Computer Applications

If int a[] = {7, 3, 4, 8, 9, 2}; what are the values of x and y?

(a) x = a[1] * a[0] + a[3]

(b) y = a.length

Java Arrays

7 Likes

Answer

(a) Since array index begin from 0, the given expression is evaluated as follows:

x = a[1] * a[0] + a[3]
⟹ x = 3 * 7 + 8
⟹ x = 29

(b) length of an array is the number of elements in an array. Thus, y = 6.

Answered By

4 Likes


Related Questions