February 2014
Beginner
1248 pages
62h 25m
English
The arithmetic compound assignment operators and the increment and decrement operators can be used to simplify program statements. For example, the three assignment statements in Fig. 4.12 (lines 26, 28 and 31)
passes = passes + 1;failures = failures + 1;studentCounter = studentCounter + 1;
can be written more concisely with compound assignment operators as
passes += 1;failures += 1;studentCounter += 1;
with prefix increment operators as
++passes;++failures;++studentCounter;
or with postfix increment operators as
passes++;failures++;studentCounter++;
When incrementing or decrementing a variable in a statement ...
Read now
Unlock full access