Computer Sciences > Gate 2016 Set-2 > Functions
Consider the following program:
Note: max(x,y) returns the maximum of x and y.
The value printed by this program is_________-
int f(int *p, int n)
{
if (n <= 1) return 0;
else return max(f(p+1,n-1),p[0]-p[1]);
}
int main()
{
int a[] = {3,5,2,6,4};
printf("%d", f(a,5));
}
{
if (n <= 1) return 0;
else return max(f(p+1,n-1),p[0]-p[1]);
}
int main()
{
int a[] = {3,5,2,6,4};
printf("%d", f(a,5));
}
Note: max(x,y) returns the maximum of x and y.
The value printed by this program is_________-
Correct : a
Similar Questions
A function f : N+ β N+, defined on the set of positive integers N+, satisfies the following
properties:
f(n) = f(n/2) if nis even
f(n) = f(n+5) if nis od...
A function f : N+ β N+, defined on the set of positive integers N+, satisfies the following
properties:
f(n) = f(n/2) if nis even
f(n) = f(n+5) if nis od...
A function f : N+ β N+, defined on the set of positive integers N+, satisfies the following
properties:
f(n) = f(n/2) if nis even
f(n) = f(n+5) if nis od...
Total Unique Visitors
Loading......