main() { int a=10,b=30,c=0; if( c =({a+b;ba;})) { printf("%d",c); } }
Here {a+b;ba;} is one area. In this, you wrote 2 statements. It is actually regarded as
{ c=a+b; c=ba; }
The initial value of c is 40 due to a+b . Again c changes to ba . To prove this, we consider three cases.
(1).
if(c=({(a=a+b);;})) { printf("%d\n",c); printf("%d\n",a); }
Here o / p - c = 40 and a = 40; Because at the end of the field (ie) in the last statement there is a fictitious (;). therefore c=a+b is o / p. (2)
if(c=({(a=a+b);ba;})) { printf("%d\n",c); printf("%d\n",a); }
Here o / p is c = -10, a = 40. Because the last statement is ba . this value is assigned c. (3) main () {
int a=10,b=30,c=0; if(c=({(a=a+b);0;})) { printf("%d\n",c); printf("%d\n",a); } printf("%d\n",c); }
Here o / p is only c = 0. If not, due to the last operator 0;
C follows the procedural orientation. And associativity () remains to the right.
source share