Home » C Arithmetic Operators – Complete Guide with Examples for Beginners

C Arithmetic Operators: Beginner's Guide

If you are starting your journey in programming, learning C programming is one of the best decisions. C is known as a foundational language, meaning many modern programming languages are built based on it.

C is a general-purpose programming language used to build:

  • Operating systems
  • Embedded systems
  • Software applications

It is powerful, fast, and widely used.

What Are Operators in C?

In simple words:

Operators are symbols that perform operations on values.

For example:  5 + 3

Here:
  • 5 and 3 are values (called operands)
  • + is an operator

What Are Arithmetic Operators in C?

Arithmetic operators are used to perform basic mathematical calculations like addition, subtraction, multiplication, and division.

They are essential because:

  • Every program needs calculations
  • Used in billing, banking, games, etc.

List of Arithmetic Operators in C

OperatorNameDescriptionExampleResult
+AdditionAdds two values5 + 38
-SubtractionSubtracts right from left5 - 32
*MultiplicationMultiplies two values5 * 315
/DivisionDivides left by right5 / 22 (int) or 2.5 (float)
%ModulusReturns remainder (integers only)5 % 21

Explanation of Each Operator (Step-by-Step)

Addition Operator (+)

Definition:

Adds two values together.

 Syntax:

result = a + b;

Example:

 
#include <stdio.h>

int main() {
    int a = 5, b = 3;
    int sum = a + b;

    printf("Sum = %d", sum);
    return 0;
}

Output: Sum = 8

Real-Life Analogy:

Adding apples: 5 apples + 3 a pples = 8 apples

Subtraction Operator (-)

Definition:

Subtracts one value from another.

 Syntax: result = a b;

Example:

int result = 10 - 4;
printf("%d", result);

Output:

Real-Life Analogy:

You had ₹10, spent ₹4 → ₹6 left.

Multiplication Operator (*)

Definition:

Multiplies two values.

Syntax:  result = a * b; 

 Example:

int result = 6 * 3;
printf("%d", result);

Output: 18 

Real-Life Analogy:

6 packets × 3 biscuits = 18 biscuits

Division Operator (/)

Definition:

Divides one value by another.

 Syntax:  result = a / b;

Example:

int result = 10 / 2;
printf("%d", result);

Output: 

Important:

If both numbers are integers → result is integer

int result = 5 / 2;
printf("%d", result);

Output:  2

Real-Life Analogy:

10 chocolates shared between 2 people → each gets 5

Modulus Operator (%)

The modulus operator (%) in C returns the remainder after dividing one number by another.

Syntax: result = a % b;

Example:

int result = 5 % 2;
printf("%d", result);

Output:

Real-Life Analogy:

5 chocolates divided among 2 people → 1 chocolate remains

Increment Operator (++)

The increment operator (++) increases the value of a variable by 1.

 Syntax: a++;

 Example:

int a = 5;
a++;
printf("%d", a);

Output: 6

 Real-Life Analogy:

Step counter:  5 steps → +1 → 6 steps

Decrement Operator (–)

Definition:

Decreases the value by 1.

Syntax: a;

Example:

int a = 5;
a--;
printf("%d", a);

Output: 4

Real-Life Analogy:

Battery level: 5 → drops to 4

Detailed Examples with Code

Example 1: Basic Calculator

#include <stdio.h>

int main() {
    int a = 10, b = 5;

    printf("Addition: %d\n", a + b);
    printf("Subtraction: %d\n", a - b);
    printf("Multiplication: %d\n", a * b);
    printf("Division: %d\n", a / b);

    return 0;
}

Explanation:

  • #include <stdio.h> → allows printing
  • int main() → starting point
  • printf() → displays output

Example 2: Increment & Decrement

#include <stdio.h>

int main() {
    int a = 5;

    printf("Original: %d\n", a);
    a++;
    printf("After Increment: %d\n", a);

    a--;
    printf("After Decrement: %d\n", a);

    return 0;
}

Operator Precedence & Associativity

What is Operator Precedence?

 It defines which operation happens first

Example: int result = 5 + 3 * 2;

Output: 11

Because:

  1. Multiplication first → 3 × 2 = 6
  2. Then addition → 5 + 6 = 11

Order of Execution

PriorityOperator
High++, —
Medium*, /, %
Low+, –

Associativity

Direction of evaluation

Example: 10 5 2

Left to right:  (10 – 5) – 2 = 3

Real-World Use Cases

Arithmetic operators are used everywhere:

Banking Apps

  • Balance calculation
  • Interest calculation

Billing Systems

  • Total bill
  • Tax calculation

Games

  • Score updates
  • Health reduction

Calculators

  • Basic operations

Best Practices

TipReason
Use (float) for accurate divisionPrevents integer truncation
Avoid modulus with float types% only works with integers
Check divisor before divisionPrevent division by zero error

Common Mistakes to Avoid

MistakeProblem
5 / 2 = 2.5 (wrong)Result is 2 if both are int
5.0 % 2 (invalid)Modulus only works on ints
Division by zeroRuntime error

FAQs on C Arithmetic Operators

1. What are arithmetic operators in C?

Arithmetic operators are symbols used to perform mathematical operations like addition, subtraction, multiplication, and division.


2. What is the modulus operator in C?

It returns the remainder after division of two numbers.


3. What is the difference between ++a and a++?

  • ++a → increment first
  • a++ → increment later

4. Why does 5/2 give 2 in C?

Because both values are integers, so the result is also an integer.


5. Can modulus work with float values?

No, % only works with integers.

Scroll to Top