ProgrammingHardIBM · Deloitte pattern

What is printed?

What is printed?
int main(void) {
    int n = 6;
    int result = 1;
    for (int i = n; i > 1; i--) result *= i;
    printf("%d", result);
}
  1. A. 6
  2. B. 0
  3. C. 720
  4. D. 120

Correct answer: C. 720

This computes 6! by multiplying 6*5*4*3*2 (stopping once i reaches 1, since the loop condition is i>1): 720.

More C Programming questions

Exams that ask this topic