Skip to content
Related Articles

Related Articles

Improve Article
GATE | GATE CS 1999 | Question 49
  • Last Updated : 23 Oct, 2017

Consider the following C function definition.

int Trial (int a, int b, int c)
{
    if ((a >= b) && (c < b) return b;
    else if (a>=b) return Trial(a, c, b);
    else return Trial(b, a, c);
}

The function Trial:
(A) finds the maximum of a, b and c
(B) finds the minimum of a, b and c
(C) finds the middle number of a, b and c
(D) None of the above


Answer: (D)

Explanation: Trial (a,b,c) return the median element of the a, b and c,but not middle element of a , b and c. But if a = b = c, then infinite loop.
So, Option (D) is correct.

Quiz of this Question

Attention reader! Don’t stop learning now. Learn all GATE CS concepts with Free Live Classes on our youtube channel.

My Personal Notes arrow_drop_up
Recommended Articles
Page :