ProgrammingHardCompetitive coding (CP)

What is printed?

What is printed?
#include <stdio.h>
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int main(void) {
    printf("%d", gcd(gcd(84, 126), 210));
}
  1. A. 21
  2. B. 6
  3. C. 42
  4. D. 84

Correct answer: C. 42

gcd(84, 126) = 42, and gcd(42, 210) = 42 since 42 divides 210.

More C Programming questions

Exams that ask this topic