I still remember the confused silence because of arithmetic operators that filled the room one morning. It was a crisp Tuesday, third week into our C programming course. I walked in with a slide that had just one line: “Write a program to calculate the area of a rectangular garden with length 15 meters and breadth 10 meters.” Now, this isn’t rocket science. I expected some quick nods. But instead, I got squints. Puzzled expressions. Some students started whispering.
I asked, “What’s the formula for area?”
A voice from the back: “Length × Breadth.”
“Exactly. So what do you need to do?”
Silence. Then one student, Rajiv, muttered, “Sir… can we use * in C?”
I smiled. That was it. That was the crack in the dam. That’s when I realized something crucial: arithmetic operators, the simplest building blocks of logic, aren’t always intuitive for beginners especially in a syntax heavy language like C.
And so began one of the most engaging lectures of my semester: Arithmetic Operators in C.
Why Arithmetic Operators Matter (More Than We Admit)
Programming is math with syntax. Whether you’re calculating EMI, billing a customer, or controlling a drone somewhere behind the scenes, numbers are dancing. And arithmetic operators are the choreographers.
In C, these are your tools:

At first glance, it looks obvious. I mean, even a calculator has these.
But C has quirks. And if you don’t know them, you’ll get gibberish for output and spend hours chasing a bug that’s not even there.
Let me walk you through this with stories, code, and classroom moments.
Integer Division: The Silent Killer
I once put this on the board:
int a = 5, b = 2;
printf(“%d”, a / b);
Then I asked the class, “What’s the output?”
Most replied “2.5”.
I nodded. “Now, compile and run it.”
They did. The screen said: 2
The look of betrayal on their faces was priceless.
Riya literally gasped, “What?! Where’s the point five?”
I chuckled. “Welcome to integer division.”
In C, if both operands of / are integers, the result is also an integer. The decimal part is discarded not rounded. It’s truncated. You want a floating point result? At least one operand has to be float or double.
float a = 5, b = 2;
printf(“%f”, a / b); // Output: 2.500000
Or you could cast:
int a = 5, b = 2;
printf(“%f”, (float)a / b); // Output: 2.500000
So the same operator / behaves differently based on the data types. And this leads us to one of my golden rules:
In C, operators don’t just act. They negotiate with data types.
The Modulus Operator: Unsung Hero of Logic
The % operator gets ignored a lot, especially by beginners.
Until they try to write a program to check if a number is even or odd.
int n = 7;
if(n % 2 == 0)
printf(“Even”);
else
printf(“Odd”);
That’s % in action. It gives you the remainder of division.
During a workshop on sensor data processing, one student asked how to log every 10th reading from a sensor. I told him to use:
if(i % 10 == 0)
Eyes lit up. “Oh! So I don’t need a counter or array?”
“Nope. % is your friend.”
It’s a tiny operator that solves event triggers, wraparounds, and partitioning problems better than any fancy loop logic.
Addition and Subtraction: Basic, But Not Always Simple
A student once told me, “Sir, I wrote this code, but the result is weird.”
Here’s what he had:
int result = 1000 + 5000 7000 + 2000;
Expected 1000, but got 1000 only because he was lucky with how C evaluated the expression. This became a segue into associativity.
C evaluates + and from left to right.
So:
1000 + 5000 = 6000
6000 7000 = 1000
1000 + 2000 = 1000
I drew this out on the board and watched the confusion dissolve.
Operators may be simple, but expression evaluation order can ruin your logic if you’re not careful.
Multiplication Comes Alive: The Garden Example
Back to the garden.
int length = 15, breadth = 10;
int area = length * breadth;
printf(“Area = %d”, area);
Every year, this example lands beautifully. It’s real. It’s familiar.
And it sets up the importance of type correctness.
What if length was float?
float length = 15.5, breadth = 10;
float area = length * breadth;
Then area becomes 155.0.
“Will it still work with int?” a student once asked.
“Yes, but you’ll lose the .5”
And that day, we talked about type promotion. When you multiply int and float, C promotes the int to float. The result is always in the higher data type.
int x = 5;
float y = 2.0;
float z = x * y; // x becomes 5.0, result is 10.0
Operator Precedence: Who Goes First?
Then there’s the big debate.
int a = 2, b = 3, c = 4;
int result = a + b * c;
Some say 20, others say 14. The truth?
Multiplication has higher precedence.
So it’s:
b * c = 12
a + 12 = 14
I use a metaphor here.
“Think of operators as a family at dinner. The multiplication guy is older than the addition guy, so he gets to eat first.”
And if there’s a tie? Associativity decides.
int result = a b + c;
Here, and + have equal precedence. So left to right applies:
a b = 1
1 + c = 3
One small change like adding brackets can flip the result.
Common Mistakes and Debugging Tales
- Using % with floats
float x = 5.5, y = 2.2;
printf(“%f”, x % y); // Compilation error
C doesn’t support % with float. Only integers allowed.
- Forgetting integer division
int avg = total / count; // Both int
If total = 10 and count = 3, average is 3, not 3.33.
Fix:
float avg = (float)total / count;
- Wrong precedence assumption
int a = 5, b = 2, c = 3;
int res = a + b / c;
Expected: (5 + 2) / 3 = 2.33 → 2
Actual: b / c = 0, then a + 0 = 5
And so the output is 5, not 2.
These moments are golden. Each error is a learning milestone.
Bringing Real Life into Code
Here’s how I’ve made operators come alive in class:
- Banking: Balance = income expenses
- Sensors: Check overflow using modulus
- Age Calculator: currentYear birthYear
- Gaming logic: Health = health damage; Score += points
Programming isn’t just about writing code. It’s about modeling real world behavior in logic. And arithmetic operators are your first step into that world.
Conclusion: The Foundation That Supports the Tower
I end my operator lectures with one line:
“There is no real program without an operator. They’re the verbs in the grammar of logic.”
Students nod. Some still look overwhelmed. But I know that over time, they’ll realize this was the class where they stopped copying code and started understanding it.
So next time you write a + b, pause. You’re not just adding numbers.
You’re telling the computer how the world works one operator at a time.
Can I use % with floating point numbers in C?
No. The % operator only works with integers. For floating point remainders, use fmod() from math.h.
What happens if I divide two integers and assign the result to a float?
If both operands are int, the division truncates the decimal part first. Casting at least one operand to float fixes this.
float result = (float)a / b;
Do operators have different precedences?
Yes. *, /, and % have higher precedence than + and . Use parentheses when in doubt.