what is the the output and how the code snippet works? | SoloLearn: Learn to code for FREE!

+1

what is the the output and how the code snippet works?

i=(2,3,4); printf("%d",i);

2/4/2020 11:50:30 AM

Chinnmay B S

2 Answers

New Answer

+2

You can assign a variable with only one value. If there is more than one value last is used, I.e. 4. So output is 4.

0

comma operator evaluates lhs operand and discard the result. so between 2,3 2 is discarded and 3 is kept between 3,4 3 is discarded and 4 is kept. After that nothing more to evaluate so 4 is assigned to i