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

Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.

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.