Wednesday, September 19, 2007

No more drawing

What problems did you encounter while developing your solution? How do you plan to overcome
them?/How did you overcome them?

Today, for Worksheet A3.2, I could not understand problem 14. I dont understand why:

b=2;
a=b++;

The result of that is

a=2
b=3


It seems that they should be the same, but they aren't. Why is that? I plan to overcome this problem by asking you.

1 comment:

Ms. Petr said...

This is that special case. If the increment operator is on the right, then the assignment happens before the things is incremented. If it's the opposite:
a=++b
then they would both end up being equal.