ExamVeda
Login
Home
Operators and Expressions
?

What will be the output of the following program?
void main()
{
      int a, b, c, d;
      a = 3;
      b = 5;
      c = a, b;
      d = (a, b);
      printf("c=%d d=%d", c, d);
}

Answer & Solution
Correct Answer: Option B

The comma operator evaluates both of its operands and produces the value of the second. It also has lower precedence than assignment. Hence c = a, b is equivalent to c = a, while d = (a, b) is equivalent to d = b.

Examveda
Question posted by Examveda
Community

Join the Discussion

1 Comment
Hemanth Tunuguntla
Hemanth Tunuguntla 9 years ago
Can you please give me the explanation in breifly as compared with the above mentioned answer