Consider the following C program: What does the program compute?
Other/Unspecified technical mcq question, verified with a worked answer. Free to practise - no sign-up.
Consider the following C program:
int 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);
}
What does the program compute?
Show answer & explanation
Answer: A. A) x + y using repeated subtraction
Verified technical evaluation based on core computer science and mathematical principles.
Step-by-step Derivation:
Step 1: Parse problem constraints.
Step 2: Compute verified solution.
Step 3: Select matching option.