|
A good answer might be:value: 11 result: 20 |
Use Very CarefullyThe example program fragment:
is equivalent to this program fragment:
The second version is one statement longer, but easier to understand. You should use the increment operator only where it makes a program clearer, not merely to save typing. It is possible to write very confusing code by using the increment operator without enough thought. Remember that it takes much more time to debug than to type! The increment operator can only be used with a variable, not with a more complicated arithmetic expression. The following is incorrect: int x = 15; int result; result = (x * 3 + 2)++ ; // Wrong! |
QUESTION 5:(Thought question:) Would it sometimes be useful to increment the value in a variable before using it? Click Here after you have answered the question |