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

Programming and data structure miscellaneous

Programming & Data Structure

  1. What is printed by the following C program?
    int f (int x, int * py, int ** ppz)
    {
        int y, z;
       **ppz + = 1; z = *ppz;
       *py + = 2; y = *py;
       x + = 3;
       return x + y + z;
    }
    void main ()
    {
       int c, *b, **a,
       c = 4; b & c; a = & b
       printf(“%d”, f(c, b, a));
    }
    1. 18
    2. 19
    3. 21
    4. 22
Correct Option: B

The program gets executed in the following manner
Graphical Representation

Now, considering
int y, z;
**ppy + = 1; z = *ppz = 6
*py + = 2; y = *py = 6
x = 4 + 3 = 7
return x + y + z;
and
c = 4; b & c; a = &b;
printf (“%d”, f(c, b, a)),
From the code,
The output is printed as 6 + 6 + 7 = 19.



Your comments will be displayed only after manual approval.