Home » Programming & Data Structure » Programming and data structure miscellaneous » Question

Programming and data structure miscellaneous

Programming & Data Structure

  1. Consider the following program :
    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));
    }
    Note : max(x, y) returns the maximum of x and y. The value printed by this program is ________ .
    1. 0
    2. 1
    3. 2
    4. 3
Correct Option: D

Assume base address of array a is 100.




Your comments will be displayed only after manual approval.