GATE CS 2014, set 2 · Question 21 · Programming and Data Structures · Multiple choice (MCQ) · 1 mark · −1/3 for a wrong answer

Suppose n and p are unsigned int variables in a C program. We wish to set p to ⁿC₃. If n is large, which one of the following statements is most likely to set p correctly?

  1. (A) p = n * (n-1) * (n-2) / 6;
  2. (B) p = n * (n-1) / 2 * (n-2) / 3;
  3. (C) p = n * (n-1) / 3 * (n-2) / 2;
  4. (D) p = n * (n-1) * (n-2) / 6.0;
Answer

Answer (B)

Answer from the official GATE CS 2014 answer key.

The step-by-step solution, where available, is part of GATE CS Pro. See what Pro includes