ProgrammingHard
#define MAX(a, b) ((a) > (b) ? (a) : (b)) printf("%d", MAX(3, 2 + 2)); What is printed?
- A. 3
- B. 5
- C. 7
- D. 4
Correct answer: D. 4
The argument 2 + 2 is fully evaluated inside the macro's parentheses, so the larger value 4 is printed.
More C Programming questions
- long long r = 1; for (int i = 0; i < 40; i++) r = r 2 % 1000000007; printf("%lld", r); What is printed (2^40 mod 10^9 + 7)?
- A linked list holds 10^5 nodes and must answer 10^5 queries for the k-th node. Which approach is correct and fast enough?
- An in-place sort on 10^6 ints must not use more than a few kilobytes of extra memory. Which algorithm fits?
- A quicksort with a poor pivot choice on already sorted input of n elements has what time?
- A hash table with 2^20 slots holds 2 x 10^5 keys and uses a good hash. What is the expected cost of a successful lookup?
- For n = 10^5, which expression correctly counts the pairs (i, j) with i < j where a[i] + a[j] equals a target, in O(n log n) time?