Operators and Expressions
Operators combine values: arithmetic, comparison and logical.
About this topic
Operators are symbols that perform actions on values, and an expression is a combination of values, variables and operators that produces a result. Arithmetic operators include plus, minus, times, divide, modulus (remainder) and exponent. Comparison operators such as equals, not equals, greater than and less than produce true or false, and logical operators AND, OR and NOT combine those results.
Operator precedence decides the order of evaluation, following the same idea as BODMAS or PEMDAS: brackets first, then powers, multiplication and division, then addition and subtraction. So 2 + 3 * 4 is 14, while (2 + 3) * 4 is 20. Using brackets makes intentions clear.
The modulus operator is very useful: 17 mod 5 is 2, and a number mod 2 equal to 0 means it is even. Mistakes are common with equality: a single equals sign assigns a value, but a double equals sign compares. Integer division may also surprise you, since 7 divided by 2 can be 3 rather than 3.5 in some languages. Test small expressions to confirm what they do.
Key ideas
- + − × ÷ and % (remainder)
- ==, !=, <, >
- and, or, not
Quick check
Use cases: where Operators and Expressions helps
- Homework: review the key idea behind Operators and Expressions before you start a problem set.
- Exam revision: use the quick check to test whether you can recall Operators and Expressions without notes.
- Visual learning: play with the interactive lab to see how Operators and Expressions changes when you adjust its inputs.
- Teaching a friend: explain Operators and Expressions in your own words, then compare your version with the key ideas.
Computing ideas run phones, search engines, games and the wider internet.
Frequently asked questions
What is Operators and Expressions?
Operators combine values: arithmetic, comparison and logical.
What will I learn in Operators and Expressions?
+ − × ÷ and % (remainder). ==, !=, <, >. and, or, not.
Is Operators and Expressions part of Computer Science?
Yes. It is one of 80 Computer Science topics on LearnViz HighSchoolEdu, with 3 key ideas, a live animation and a quick check.
Does the Operators and Expressions lab work on a phone or tablet?
Yes. The animation resizes to fit your screen and supports touch, so you can drag, tap and slide with your finger.
How should I study Operators and Expressions?
Read the summary and key ideas first, play with the interactive lab to see the idea in motion, then answer the quick check. If you get a question wrong, go back to the key idea it tests.
Do I need an account, and is my progress saved?
No account is needed. Marking a topic as learned is saved in your own browser, so it stays on that device and is not sent to a server.