ProgrammingHardTCS NQT · Infosys · Product Company SDE
What is the output of this C program (assume a typical 64-bit platform: int 32 bits, long and pointers 64 bits)? #include <stdio.h> int g(int a, int b) { return b ? g(b, a % b) : a; } int d(int n) { return n ? n % 10 + d(n / 10) : 0; } int main(void) { printf("%d %d", g(80, 22), d(469)); return 0; }
- A. 2 19
- B. 2 20
- C. 2 3
- D. 3 19
Correct answer: A. 2 19
Euclid: gcd(80,22) = 2; d() sums decimal digits of 469 = 19.
More C Programming questions
- What is the output of this C program (assume a typical 64-bit platform: int 32 bits, long and pointers 64 bits)? #include <stdio.h>…
- What is the output of this C program (assume a typical 64-bit platform: int 32 bits, long and pointers 64 bits)? #include <stdio.h> int…
- What is the output of this C program (assume a typical 64-bit platform: int 32 bits, long and pointers 64 bits)? #include <stdio.h> int…
- What is the output of this C program (assume a typical 64-bit platform: int 32 bits, long and pointers 64 bits)? #include <stdio.h>…
- What is the output of this C program (assume a typical 64-bit platform: int 32 bits, long and pointers 64 bits)? #include <stdio.h> int…
- What is the output of this C program (assume a typical 64-bit platform: int 32 bits, long and pointers 64 bits)? #include <stdio.h> int…