C | Operators | Question 24

filter_none

edit
close

play_arrow

link
brightness_4
code

#include <stdio.h>
int main()
{
   int x = 10;
   int y = (x++, x++, x++);
   printf("%d %d\n", x, y);
   return 0;
}

chevron_right


(A) 13 12
(B) 13 13
(C) 10 10
(D) Compiler Dependent


Answer: (A)

Explanation: The comma operator defines a sequence point, so the option (d) is not correct.
All expressions are executed from left to right and the value of rightmost expression is returned by the comma operator.

Quiz of this Question

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Article Tags :
Practice Tags :


3


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.