ProgrammingHardProduct-company MCQ pattern

Assume 32-bit int. What is printed?

Assume 32-bit int. What is printed?
int a = 4, b = 7;
int max = (a > b) ? a : b;
int min = (a < b) ? a : b;
printf("%d %d %d", max, min, max + min);
  1. A. 7 4 11
  2. B. 4 7 11
  3. C. 7 7 14
  4. D. 4 4 8

Correct answer: A. 7 4 11

a > b (4>7) is false, so max takes the else-branch, b=7. a < b (4<7) is true, so min takes the true-branch, a=4. max+min = 7+4 = 11.

More C Programming questions

Exams that ask this topic