#include<stdio.h>
#include<stdlib.h>
int main() {
int x = 5;
int y = 0;
x++, y = x*x;
printf("x is %d\n", x);
printf("y is %d\n", y);
}
Question: Why the output of the above code is:
x is 6
y is 36
instead of
x is 6
y is 25
?
Reasoning:
I am thinking it should be the latter because assignment operator has higher precedence than comma and therefore first an assignment to y
should happen setting it to 25
and then x
should be evaluated and set to 6
.