Chapter Table of Contents
Ch. 4 OperatorsSection Table of Contents
Quick Summary
Before we move on here's a brief review of all the operators we learned so far:
Style Guide
When using binary operators, you should leave at least 1 space between the operands (the things being operated on) and the operator. When using a unary operator, you should not leave any space. Remember, you should follow style conventions to help code be readable to humans.
Good style:
a += 1; a = 5 - 1; a++;
Bad style:
a+=1 a=5 -1; a ++;
Lots of Operators!
Now that you’ve learned all of these operators, you might be tempted to do something like this:
a += b++ * --a % 50;
However, as you probably can see, this is not very readable. Therefore, if you have a lot of operators, you probably want to separate them into multiple lines.
Previous Section
4.3 Increment and DecrementNext Section
4.5 PracticeCopyright © 2021 Code 4 Tomorrow. All rights reserved.
The code in this course is licensed under the MIT License.
If you would like to use content from any of our courses, you must obtain our explicit written permission and provide credit. Please contact classes@code4tomorrow.org for inquiries.