Ternary, Comma and goto
cond ? a : b is a short if expression. The comma operator evaluates left to right. goto jumps to a label and is mostly used for error cleanup in C.
Example
int a = 7;
printf("%s\n", a % 2 ? "odd" : "even");
int x = (1, 2, 3);
printf("%d\n", x);
int i = 0;
loop:
if (i < 3) { printf("%d ", i++); goto loop; }
printf("\n");Result
odd 3 0 1 2
Exercise
Pick one of two values.
int m = a > b a : b;
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.