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));
}- A. 21
- B. 6
- C. 42
- D. 84
Correct answer: C. 42
gcd(84, 126) = 42, and gcd(42, 210) = 42 since 42 divides 210.
More C Programming questions
- What is printed? c #include <stdio.h> int rev(int n, int acc) { return n == 0 ? acc : rev(n / 10, acc 10 + n % 10); } int main(void) {…
- What is printed? The program checks whether the low four bits of each argument form a binary palindrome. c #include <stdio.h> unsigned…
- What is printed? Assume unsigned int is 32 bits. c #include <stdio.h> int main(void) { unsigned x = 1, r = 0; for (int i = 0; i < 32; i++)…
- What is printed? c #include <stdio.h> int main(void) { unsigned n = 1000; int p = -1; while (n) { n >>= 1; p++; } printf("%d", p); }
- Would the product of 50000 and 50000 overflow a 32-bit int? The program checks with a 64-bit product. What is printed? c #include…
- What is printed? c #include <stdio.h> int main(void) { const char s = "112233"; int count[10] = {0}; for (const char p = s; p; p++)…