Correct memory diagram? Need a second opinion from someone experienced

Can someone with more experience please verify if this is the correct memory diagram.

Can you explain your thinking? How did you arrive at the answer?

By the way, you might want to check with your teacher about asking questions like this. I wouldn’t want you to get in trouble for violating your academic honesty policy.

So ‘a’ is 12 then f1 is called and I think x become a++ which is 13. Then y calls function f2 so k would be 14. After that I have no idea I’m just guessing.

  • Indeed a++ increases a by 1 and it becomes 13.
  • However, b/c it’s the postfix version of the unary operator ++, it is evaluated as the previous value 12.
  • Therefore, 12 is the argument passed to function f1(int x), not 13.
  • My guess the final result is 17. :man_technologist:

The final result should be 18… if i‘m not completely wrong :sweat_smile: