0

Explain

a[a[2]]

28th Feb 2020, 10:22 AM
Ajith
Ajith - avatar
5 Respuestas
+ 4
Ajith your posted lines of code have many problems like first a is not declared so instead of x you have to use a than which elements you will aceess is out of bound like this way a[2]=3 a[a[2]= a[3] = garbage value as length of array is 3 and you are accessing 4th element of array which resulted in garbage value.
28th Feb 2020, 10:31 AM
DishaAhuja
DishaAhuja - avatar
+ 2
Example a=[1, 2,0] a[2] = 0 a[a[2]]=a[0]=1
28th Feb 2020, 10:24 AM
Oma Falk
Oma Falk - avatar
+ 2
will make an IndexOutOfBoundError because a[2]=3 and max Index is 2.
28th Feb 2020, 10:31 AM
Oma Falk
Oma Falk - avatar
0
int x[3]={1,2,3}; Printf("%d"a[a[2]]);
28th Feb 2020, 10:24 AM
Ajith
Ajith - avatar
0
Thank you guys
28th Feb 2020, 10:32 AM
Ajith
Ajith - avatar