A
Q. The following function computes the maximum value contained in an integer array p[] of size n (n >= 1)
Code:
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];
}
{
int a=0, b=n-1;
while (__________)
{
if (p[a] <= p[b])
{
a = a+1;
}
else
{
b = b-1;
}
}
return p[a];
}
- Correct Answer - Option(D)
- Views: 20
- Filed under category C Programming
- Hashtags:
Discusssion
Login to discuss.