I believe that the answer would be 234. This has helped me and I will explain what I understand and please correct me if I am mistaken. You have assigned weight with
int weight = 111;
You later have reassigned weight by modifying it by a value of 123
weight = weight + 123;
I'm assuming this is done so that you can have a starting value and then later modify it more easily. My question now is: after
weight = weight + 123;
runs does the permanent value of weight become 234 or does it remain 111?
Thanks for your help!
Campbell Ritchie wrote:Welcome to the Ranch both of you
In a line like weight = weight + 150; you need to remember that the + operator has a higher precedence than the assignment operator =
Work out what weight is at the end of this code