Operators in Programming
5. Operators in Programming
Operators are the little symbols that tell a computer what kind of action to perform. They are a big part of programming because they help you do math, compare values, make decisions, and store data in variables. If variables are the boxes where information is kept, operators are the actions that work on those boxes.
a. Arithmetic Operators
Arithmetic operators are used for basic math operations. They help you add, subtract, multiply, divide, and sometimes find the remainder of a number. These are some of the first operators beginners learn because they feel familiar.
Common arithmetic operators include:
- Addition.
- Subtraction.
- Multiplication.
- Division.
- Modulus, which gives the remainder after division.
For example, if you add 5 and 3, the result is 8. If you divide 10 by 2, the result is 5. If you divide 10 by 3 and use modulus, the remainder is 1. In programming, these operators are used in calculators, score systems, billing apps, and many other places.
A simple way to remember them is this: arithmetic operators help a program “do the math.”
b. Comparison Operators
Comparison operators are used to compare two values. They do not give you a number as the answer; instead, they tell you whether something is true or false. That is why they work closely with Boolean values and decision-making statements.
Common comparison operators include:
- Equal to.
- Not equal to.
- Greater than.
- Less than.
- Greater than or equal to.
- Less than or equal to.
For example, if you check whether 10 is greater than 5, the result is true. If you compare 4 and 4 using equal to, the result is also true. If you compare 7 and 9 using greater than, the result is false. These operators are very useful when a program needs to test conditions, such as checking age, marks, password values, or stock availability.
Comparison operators help a program answer questions like: “Is this value bigger?” or “Are these two things the same?”
c. Logical Operators
Logical operators are used to combine or modify conditions. They are especially useful when a program must make decisions based on more than one condition at the same time. These operators usually work with true and false values.
The most common logical operators are:
- AND, which is true only if both conditions are true.
- OR, which is true if at least one condition is true.
- NOT, which reverses a condition.
For example, if a student must score above 40 and also attend class regularly, both conditions must be true to pass. That is an AND situation. If a user can log in with either a username or an email address, that may use OR. If a condition says “not false,” then NOT changes it to true.
Logical operators are powerful because real-world decisions are rarely based on just one condition. They help programs think in a more human-like way by combining checks and rules.
d. Assignment Operators
Assignment operators are used to store values in variables. The most common assignment operator is the equal sign, which means “put this value into the variable.” These operators are very important because every program needs a way to save and update information.
For example, if a variable named score is given the value 10, the program stores 10 inside score. Some assignment operators also combine math with assignment, such as adding a value to the current variable and saving the result again. This is helpful when updating counters, totals, and running values.
Common assignment actions include:
- Assigning a value.
- Adding and then assigning.
- Subtracting and then assigning.
- Multiplying and then assigning.
- Dividing and then assigning.
A simple example is this: if a variable starts at 5 and you add 2 to it using an assignment update, the new value becomes 7. This saves time and makes code shorter and easier to read.










