I have no idea how the following code returns 10. I expected that the x>2||(y%2) part meant that x should either be bigger than two or bigger than y%2.
int x, y = 1;
for (x = 10; x > 2 || (y % 2); x--) {
y = y + 1;
}
printf ("%d\n", y);
when I change it to the following, I get my expected output (11):
int x, y = 1;
for (x = 10; x > 2 || x > (y % 2); x--) {
y = y + 1;
}
printf ("%d\n", y);
how is the second code different from the first one?