Every time your code does math, compares two values, or makes a decision — it uses operators. Operators are the symbols that tell your program what to do with data. Plus signs, equals signs, greater than symbols — you have seen them all before. In coding, they work the same way as in everyday math, just with a few extra tricks.
What Are Operators in Programming?
Real-Life Analogy — Calculator Buttons
Think of operators like buttons on a calculator. Your values sit on either side. The operator tells the computer what to do. The result gets stored in a variable.

Arithmetic Operators — Doing Math
If you’ve used a calculator — you already know most of these.
These are the operators you use to do math in code. They work exactly like the math you learned in school — just written slightly differently.
Basic Math Operators
The Modulo Operator — Finding Remainders
% gives you the remainder after division. Perfect for checking if a number is even or odd.
Increment and Decrement
++ adds 1. — subtracts 1. Used constantly inside loops to count up or down.
score++; // now 11
// same as score = score + 1
lives–; // now 2
// same as lives = lives – 1
Comparison Operators — Comparing Values
Comparison operators compare two values and always return true or false. Nothing else. This makes them perfect for making decisions in your code.
All Comparison Operators Explained
=== vs == — Why This Matters
== checks value only. === checks value AND type. This difference causes real bugs.
=== — never ==. The triple equals checks both value and type, which prevents bugs that are very hard to find later.Logical Operators — Combining Conditions
Check multiple things in a single line.
AND Operator
Both must be trueBoth conditions must be true for the result to be true. If even one is false — the whole thing is false.
// both must be true — if either fails, result is false
OR Operator
Just one must be trueOnly one condition needs to be true. If at least one passes — the result is true.
// just one needs to be true — either works
NOT Operator
Flips the resultFlips the result. Turns true into false, and false into true. Use it when you want to check if something is NOT the case.
// show login button — user is NOT logged in
}
Assignment Operators — Shorthand Writing
Store values faster with less code.
Assignment operators store values into variables. You already know the basic one — =. But there are shorter ways that save time and make your code cleaner.
Basic Assignment
The = operator stores a value into a variable. It does not mean “equal to” — it means “store this value here.”
score = 20; // replace with 20
Shorthand Operators
Instead of writing score = score + 5, you can write score += 5. Same result — less typing.
Operator Precedence — Which Runs First?
Code doesn’t always run left to right — it follows a specific order.
When you write an expression with multiple operators, the computer does not just run them left to right. It follows a specific order — just like BODMAS from math class.
Order of Operations in Code
First
Second
Third
Last
FAQs About Operators
Quick answers to the questions beginners ask most
What are the 4 basic operators in programming?
What does % mean in coding?
% is the modulo operator. It gives you the remainder after division — not the result itself. Developers use it to check if numbers are even or odd, and to cycle through values in loops.6 % 2 = 0 // 0 remainder = even number
7 % 2 = 1 // 1 remainder = odd number
number % 2 === 0 → even. If number % 2 === 1 → odd.What is the difference between = and == in coding?
let score = 10
Store Value5 == "5" → true
❌ Avoid5 === "5" → false
✅ Always Use= to store. Use === to compare. Never use ==.