CJCoding With Joseph
← Back to Question List
C Code Walkthrough #35

Ternary Operator Selection

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