🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Number Programs in C: all 10 questions

Quiz: Number Programs in C · Question 5 of 10

What does this print? (code)

What does this print?

#include <stdio.h>
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int main(void) {
    printf("%d %d\n", gcd(84, 36), 84 / gcd(84, 36) * 36);
    return 0;
}
  1. A.6 504
  2. B.12 252
  3. C.12 3024
  4. D.4 756
Answer & explanation

Correct answer: 12 252

84 % 36 = 12, 36 % 12 = 0, so the GCD is 12, and the LCM is 84 / 12 × 36 = 252.

Can you get the rest right without peeking?

Take the timed Quiz: Number Programs in C quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →