CJCoding With Joseph
15free / daySign inCreate account
Back to Code Walkthrough

Ternary Operator Selection

C code walkthrough · Question 35
easyOperators

Code

Read carefully. What does this print?
1#include <stdio.h>
2int main() {
3 int a = 7, b = 4;
4 int max = (a > b) ? a : b;
5 int sign = (a - b > 0) ? 1 : -1;
6 printf("%d %d", max, sign);
7 return 0;
8}

Your answer