# Correct memory diagram? Need a second opinion from someone experienced

**URL:** <https://discourse.processing.org/t/correct-memory-diagram-need-a-second-opinion-from-someone-experienced/4622>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [October 19, 2018, 12:57am UTC](https://discourse.processing.org/t/correct-memory-diagram-need-a-second-opinion-from-someone-experienced/4622 "2018-10-19T00:57:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![engg23369](https://avatars.discourse-cdn.com/v4/letter/e/e495f1/32.png) [@engg23369](https://discourse.processing.org/u/engg23369)\
**Post date:** [October 19, 2018, 12:57am UTC](https://discourse.processing.org/t/correct-memory-diagram-need-a-second-opinion-from-someone-experienced/4622/1 "2018-10-19T00:57:20Z")

</div>

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

 ![IMG_6218](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/f/fffd994bad18c25b9d075c7df2e64ccf1aa31d29.jpeg)

---

<div class="post-metadata">

**Author:** ![engg23369](https://avatars.discourse-cdn.com/v4/letter/e/e495f1/32.png) [@engg23369](https://discourse.processing.org/u/engg23369)\
**Post date:** [October 19, 2018, 12:57am UTC](https://discourse.processing.org/t/correct-memory-diagram-need-a-second-opinion-from-someone-experienced/4622/2 "2018-10-19T00:57:56Z")

</div>

![IMG_6217](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/4/4af92915d662f06c1784d2088151896c8037b20a.jpeg)

---

<div class="post-metadata">

**Author:** ![Kevin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kevin/32/2297_2.png) [@Kevin](https://discourse.processing.org/u/Kevin)\
**Post date:** [October 19, 2018, 3:21am UTC](https://discourse.processing.org/t/correct-memory-diagram-need-a-second-opinion-from-someone-experienced/4622/3 "2018-10-19T03:21:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![engg23369](https://avatars.discourse-cdn.com/v4/letter/e/e495f1/32.png) [@engg23369](https://discourse.processing.org/u/engg23369)\
**Post date:** [October 19, 2018, 4:38am UTC](https://discourse.processing.org/t/correct-memory-diagram-need-a-second-opinion-from-someone-experienced/4622/4 "2018-10-19T04:38:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [October 19, 2018, 7:43am UTC](https://discourse.processing.org/t/correct-memory-diagram-need-a-second-opinion-from-someone-experienced/4622/5 "2018-10-19T07:43:49Z")

</div>

> [@engg23369](#):
>
> … and I think _x_ become `a++` which is `13`.

- 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`. 👨‍💻

---

<div class="post-metadata">

**Author:** ![Lexyth](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lexyth/32/7403_2.png) [@Lexyth](https://discourse.processing.org/u/Lexyth)\
**Post date:** [October 22, 2018, 4:07pm UTC](https://discourse.processing.org/t/correct-memory-diagram-need-a-second-opinion-from-someone-experienced/4622/6 "2018-10-22T16:07:43Z")

</div>

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