0
Explain the output?
3 Answers
0
a[i] is evaluated as *(a + i)
so
a[2] = *(a + 2)
2[a] = *(2 + a) = *(a +2)
in other words 2[a] referes to the same element as a[2].
a[2] = 1;
2[a] is also = 1
so output will be 1.
0
the compiler converts the array operation in pointers before accessing the array elements, which means all of the following expressions mean same thing *(a+2), a[2], 2[a]:
https://code.sololearn.com/cUE4lD7fokb9/#c
BTW not sure why you have the statement a[-3]=10; but it's probably not doing what you think it's doing. specifically, the compiler will, almost definitely be able to establish statically that this is undefined behavior and, being undefined behavior, could choose to do just about anything with it; complete removal being the most likely.
0
Thank uh guys andriy kan Mohamed ELomari