+ 1
What this code mean?
3 Answers
0
the expression x?y:z returns y if x is true, and z if x is false.
(-a == 1) is false so we have
a +=4;
which is equivalent to
a=a+4
0
//initialize a to 3 and b to 4
int a =3, b=4;
//recalculate a as follow:
// if( a==-1 ){
// a=a-3
// }
// else {
// a = a+4
// }
a+=(-a==1?-3:4);
//Now a is 7
//Print a
cout<<a;
0
Thank you!