Computer Science EngineeringHardISRO SC (CS)

Consider the following C fragment. int c=0; for(int i=0;i<15;i++) for(int j=i+1;j<15;j++) for(int k=j+1;k<15;k++) c++; What is c at the end?

  1. A. 1365
  2. B. 105
  3. C. 680
  4. D. 455

Correct answer: D. 455

Simulating the loops gives 455. The distractors come from the usual slips: off-by-one at a boundary (< vs <=), dropping a loop level, or using a cruder asymptotic estimate instead of the exact count.

More Algorithms, Data Structures & Programming (ISRO CS) questions

Exams that ask this topic