1/* The expression a ? b : c evaluates to b if the value of a is true,
2 * and otherwise to c
3 */
4
5// These tests are equivalent :
6
7if (a > b) {
8 result = x;
9}
10else {
11 result = y;
12}
13
14// and
15
16result = a > b ? x : y;
17
1// | is the binary "or" operator
2// a |= b is equivalent to a = a|b
3
4#include <stdio.h>
5
6int main() {
7 int a = 10; // 00001010 in binary
8 int b = 6; // 00000110 in binary
9
10 printf("Result : %d\n", a |= b);
11 // Result is 14 which is OOOO111O in binary
12
13 return 0;
14}
1? : Conditional Expression operator
2If Condition is true ? then value X : otherwise value Y
3
4y = x==0 ? 0 : y/x
5