Computer Sciences > Gate 2016 Set-1 > Functions
The following function computes the maximum value contained in an integer array p[] of size n (n >= 1)

int max(int *p, int n)
{
    int a=0, b=n-1;
    while (__________)
    {
        if (p[a] <= p[b])
        {
            a = a+1;
        }
        else
        {
            b = b-1;
        }
    }
    return p[a];
}

The missing loop condition is
A
a != n
B
b != 0
C
b > (a + 1)
D
b != a

Correct : Functions

Similar Questions

Consider the following C program. void f(int, short); void main() { &nbsp; &nbsp; int i = 100; &nbsp; &nbsp; short s = 12; &nbsp; &nbsp; short *p = &s; &...
#144 MCQ
Consider the following C program. void f(int, short); void main() { &nbsp; &nbsp; int i = 100; &nbsp; &nbsp; short s = 12; &nbsp; &nbsp; short *p = &s; &...
#144 MCQ
Consider the following C program. void f(int, short); void main() { &nbsp; &nbsp; int i = 100; &nbsp; &nbsp; short s = 12; &nbsp; &nbsp; short *p = &s; &...
#144 MCQ

Related Topics

No tags found

Unique Visitor Count

Total Unique Visitors

Loading......