Assume that X and Y are non-zero positive integers. What does the following…

GATE · 1995 · CS · Question 2 subparts

Assume that X and Y are non-zero positive integers. What does the following pascal program segment do?

while X <>Y do
  if X > Y then
    X:=X − Y
  else
    Y:=Y − X;
write(X);

  1. A.

    Computes the LCM of two numbers

  2. B.

    Divides the larger number by the smaller number

  3. C.

    Computes the GCD of two numbers

  4. D.

    None of the above

Attempted by 2 students.

Sign up free to check your answer

Sign up free

Explore the full course: Aptitude For Gate

Loading lesson…