ProgrammingHardCompetitive coding (CP)

What is printed by this recursive Pascal triangle entry?

What is printed by this recursive Pascal triangle entry?
#include <stdio.h>
int C(int n, int k) {
    if (k == 0 || k == n) return 1;
    return C(n - 1, k - 1) + C(n - 1, k);
}
int main(void) {
    printf("%d", C(5, 2));
}
  1. A. 5
  2. B. 10
  3. C. 15
  4. D. 20

Correct answer: B. 10

C(5, 2) = C(4, 1) + C(4, 2) = 4 + 6 = 10, which is the entry in row 5 of Pascal's triangle at position 2.

More C Programming questions

Exams that ask this topic