Question 9522 – Programming
February 13, 2024Question 9578 – Programming
February 13, 2024Question 9529 – Programming
Consider the following C program
main() { int x, y, m, n; scanf ("%d %d", &x, &y); /* Assume x > 0 and y > 0 */ m = x; n = y; while (m! = n) { if (m > n) m = m - n; else n = n - m; } print f ("% d", n); }
The program computes
Correct Answer: C
Question 44 Explanation:
Given code is same as Euclid’s Algorithm for finding Greatest Common Divisor(GCD).
x + y using repeated subtraction
x mod y using repeated subtraction
the greatest common divisor of x and y
the least common multiple of x and y