edited by
763 views

3 Answers

1 votes
1 votes

B)

a=2 at first

because of associativity c=4,b=4, a= a*b which is 8. //in second line.

now b=c ( c is 4) so, b=4 and a=b i.e a=4  //in third line.

Print(a)// 4 get printed in 4th line

(b=c) i.e b gets value of c which is 4 also a==(b=c) means a== 4 which is true.// in 5th line

print(a)// 4 gets printed in 6th line

1 votes
1 votes
Correct answer is (B) 4,4

int a = 2, b, c; 
a* = b = c = 4;
/* this line works in the given manner : (a*=(b=(c=4))), i.e. first the value of c will be made 4 then 
value of b will be equal to value of c. so b also equal to 4, 
and then finally value of a is multiplied by value of b, i.e. a = a*4
so now,
     a = 8
     b = 4
     c = 4
*/
a = b = c;
/* Similarly after this line value of b is made equal to the value of c, 
and then the value of a is made equal to the value of b.
so now,
     a = 4
     b = 4
     c = 4
*/
printf(“%d”, a);
/* Here this value of a, which is equal to 4 is printed*/
a == (b = c);
/* 
Now in this line first the value of b is made equal to the value of c that is b = 4,
then it checks if value of a is equal to the value of b.
which actually it is, so this entire expression "a == (b = c);" becomes 1 i.e. true, 
but since no one is taking this 1 it becomes a garbage value and is discarded.
*/
printf(“%d”, a);
/*Now again the value of a is printed i.e. 4*/

Therefore the value printed is 44

So the correct answer is (B) 4,4

Related questions