+ 1
can anyone explain this code
following is the code for addition of two numbers without using arithematic operators.. main() { int x,y,result; x=2; y=5; char *p=0; result=(int)&((&(p[x]))[y]); printf("sum=%d",result);
1 Answer
+ 2
p==0
p[x] == *(p+x) so &(p[x]) == p+x == x
x[y] == *(x+y) so &(x[y]) == x+y (which was cast as a pointer)
x+y is then cast as an int, which is 7 and then displayed