Skip to content

Arithmetic Operators in C

What are Arithmetic Operators?

Arithmetic operators are used to perform mathematical calculations like addition, subtraction, and multiplication. They are the most basic building blocks of programming logic.

Operator Operation Description
+ Addition Adds two values together
- Subtraction Subtracts the right value from the left value
* Multiplication Multiplies two values
/ Division Divides the left value by the right value
% Modulus Returns the remainder after division

Note: While the basic behavior is the same across languages, how they handle things like "Integer Division" (e.g., 5 / 2) can vary.

C Specific Behavior

In C, integer division always truncates the decimal part. There is no built-in exponent operator (you must use pow() from math.h).

Operator Operation Description
++ Increment Increases the value by 1
-- Decrement Decreases the value by 1

Code Example

#include <stdio.h>

int main() {
    int a = 10;
    int b = 3;

    printf("%d
", a + b);    // 13
    printf("%d
", a / b);    // 3 (Integer Division)

    a++;
    printf("%d
", a);        // 11

    return 0;
}