Difference b/w a[i] and i[a]

Is there any relation between a[i] and i[a] while using arrays..can anyone help me with this....

Questions by rosuuuuu1010

Showing Answers 1 - 24 of 24 Answers

vijoeyz

  • Feb 22nd, 2008
 

They are same.  a[i] is treated as *(a+i), and i[a] is *(i+a).  And from the rule of associativity, you can see that both expressions will yield to the same result.

Thanks,
Vijay Zanvar
http://faq.zanvar.in

Actually there is no difference b/w both representations.

Both represent the value at ith location of the array.The a[i] is accessesd as *(a + i)) and i[a] as *(a + i). So conceptually both representations are same.

  Was this answer useful?  Yes

There is no difference b/w a[i] and i[a],System can understand boyh as *(a+i), *(i+a).

Let us take an eg:let address location of array named by a is "100",and a is an int type array let " i " is the 3rd eliment i.e i=2.then a[i]=*(100+2(4bytes))(=*(104) which is starting location of 3rd eliment's of array.

Now i[a] =*(2(4bytes)+100)=(*(104)) which is also represents the same 3rd eliment's starting address location. so both are same.

Thank U.

  Was this answer useful?  Yes

jintojos

  • Jun 9th, 2008
 

Bath a[i] and i[a] are same.....the variable name 'a'  contains the basic address of the  array.so a[i] means base address + index 'i' and also i[a] means base address + index 'i'

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions