+ 4
Can somebody please explain why the output 123?
int a[]={1,2,3}; int i; for(i=0;i<3;i++) { cout<< i[ a ]; }
7 Réponses
+ 15
I[a] is similar to a[I] .
As array use contiguous memory allocation,
both of them is evaluated to *(a+I)
*a = a[0].
*(a+1) = a[1]
+ 7
Answer is Syntax Error
+ 7
Hi Aniket!
I read that question as one containing a typo. As such,
cout << a[i];
Edit: Thanks for the clarification!
+ 1
Aniket good question
Manoj thanks for the great explanation
i have run this program, as Aniket said its giving output 123
so it is not a typo or syntax error
Manoj's explanation is the only one that fits here.
Thank you
+ 1
tnnx Manoj ... Great work
+ 1
because you d'ont put endl; end line
or any caracter to separate the output.
0
no but I have run it .. the output is 123