edited by
17,712 views
44 votes
44 votes

What is printed by the following C program?

int f(int x, int *py, int **ppz)			
{						                    	
    int y, z;					                		
    **ppz += 1; z = **ppz;		 // corrected z = *ppz; to 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$
edited by

4 Answers

Best answer
54 votes
54 votes

Return $x+y+z =$ return $7 + 7 + 5 =$ return $19$

So, option B $= 19$ is correct.

edited by
0 votes
0 votes
z = *ppz Shouldn't be z = **ppz ??
Answer:

Related questions

26 votes
26 votes
3 answers
3
Kathleen asked Sep 11, 2014
12,445 views
Which combination of the integer variables $x, y,$ and $z$ makes the variable $a$ get the value $4$ in the following expression?$$a=(x y)?((x z) ?x:z): ((y z) ?y:z)$$$...