Computer Sciences > GATE 2025 SET-2 > C Programming
The output of the given C code segment is ______ (Answer in integer)

Correct : 21

The correct answer is 21.
The given C code repeatedly subtracts the smaller number from the larger one until both values become equal.
This is an implementation of the Euclidean algorithm (using subtraction) to compute the GCD (Greatest Common Divisor) of two numbers.
Initially, x = 126 and y = 105.
At each step: If x > y, then x = x − y Else, y = y − x
This process continues until x = y.
The sequence eventually converges to 21, which is the GCD of 126 and 105.
Finally, the program prints the value of x, which is 21.

Similar Questions

Consider the following two functions void fun1(int n){     if(n == 0) return;       printf(“%d”, n);     fun2(n-2); &...
#175 MCQ
Consider the C functions foo and bar given below: int foo(int val) {     int x = 0;     while (val > 0)     {     &nbs...
#190 MCQ
What is printed by the following ANSI C program? #include<stdio.h> int main(int argc, char *argv[]) {     int a[3][3][3] =     {{...
#311 MCQ

Related Topics

C code output GATE 2025 GATE CS 2025 Set-2 Q33 C programming output integer output C GATE C program trace GATE GATE computer science C language C code segment GATE programming NAT GATE operator precedence C GATE GATE previous year questions

Unique Visitor Count

Total Unique Visitors

Loading......