+ 2
Why is a[1]=1?
In the following code why is a[1]=1?: int x=0; int a[]={3,4}; a[x]=++Ă; cout<<a[1]; Shouldn't a[1] be 4?
6 Answers
+ 4
++x is a pre-increment. That is done before the statement is executed. Therefore you are setting a[1] to 1.
+ 1
int x=0; ++x=1 so a[x]=a[0] becomes a[1] since ++x=1. ++x is pre-increment, hence the value is increased before we solve the expression.
0
3
0
yes me too I can not understand
0
++ has bigger priority from = and [] , so x=1 and you did a [1]=1
0
=1