Computer Science, asked by shannswami1234p7p20r, 1 year ago

please some this
and what does (++a[0]):(a[4]++) means?​

Attachments:

Answers

Answered by siddhartharao77
2

int a[] = {5,3,9,6,4};

a[0] = 5

a[1] = 3

a[2] = 9

a[3] = 6

a[4] = 4

Here, the following statement declares an array variable, a, creates an array of 5 elements of int type and assigns its reference to a.

(i)

value of a.length = 5

(ii) Ternary operator:

x = (expression) ? value if true : value if false

Now,

y = a[1] > a[3] ? (++a[0]) : (a[4]++)

  = 3 > 6 ? (True) : (False)

Here, 3 > 6 is false.. So, a(4)++ is evaluated i.e 4.

Therefore, the answer is 4.

Hope it helps!


shannswami1234p7p20r: thanks brother!!
siddhartharao77: Welcome
Similar questions