Consider the following C program
main(){ int x, y, m, n; scanf ("%d %d", &x, &y); /* x > 0 and y > 0 */ m = x; n = y; while (m != n) { if(m>n) m = m - n; else n = n - m; } printf("%d", n);} |
The program computes
a) x + y using repeated subtraction
b) x mod y using repeated subtraction
c) the greatest common divisor of x and y
d) the least common multiple of x and y
a) x + y using repeated subtraction
b) x mod y using repeated subtraction
c) the greatest common divisor of x and y
d) the least common multiple of x and y
Answer(c)
the greatest common divisor of x and y
the greatest common divisor of x and y
No comments:
Post a Comment