C Arithmetic Operators

Arithmetic Operators are used to perform common mathematical operations like addition, subtraction, multiplication, division, etc.

In this tutorial, we will learn about different Arithmetic Operators available in C programming language and go through each of these Arithmetic Operations in detail, with the help of examples.

Arithmetic Operators

The following table specifies symbol, example, and description for each of the Arithmetic Operator in C.

Arithmetic Operation Operator Symbol Example Description
Addition + a + b Returns sum of a and b.
Subtraction a – b Returns difference of b from a.
Multiplication * a * b Returns product of a and b.
Division / a / b Returns the quotient when a is divided by b.
Modular Division % a % b Returns reminder when a is divided by b.
Increment ++ a++ or ++a Increments the value of a by one.
Decrement a– or –a Decrements the value of a by one.

Addition

Addition Operator + computes the addition of the two operands and returns the result.

main.c

#include <stdio.h>

int main() {
    int a, b, result;
    a = 12;
    b = 7;
    //addition
    result = a + b;
    printf("Result : %d\n", result);
    return 0;
}

Output

Result : 19
Program ended with exit code: 0

Refer C Addition tutorial.

Subtraction

Subtraction Operator - computes the difference of right operand from left operand and returns the result.

main.c

#include <stdio.h>

int main() {
    int a, b, result;
    a = 12;
    b = 7;
    //subtraction
    result = a - b;
    printf("Result : %d\n", result);
    return 0;
}

Output

Result : 5
Program ended with exit code: 0

Refer C Subtraction tutorial.

Multiplication

Multiplication Operator * computes the product of two operands and returns the result.

main.c

#include <stdio.h>

int main() {
    int a, b, result;
    a = 12;
    b = 7;
    //multiplication
    result = a * b;
    printf("Result : %d\n", result);
    return 0;
}

Output

Result : 84
Program ended with exit code: 0

Refer C Multiplication tutorial.

Division

Division Operator + computes the division of first operand with second operand and returns the quotient of this division operation.

main.c

#include <stdio.h>

int main() {
    int a, b, result;
    a = 36;
    b = 7;
    //division
    result = a / b;
    printf("Result : %d\n", result);
    return 0;
}

Output

Result : 5
Program ended with exit code: 0

Refer C Division tutorial.

Modular Division

Modular Division Operator % computes the division of the given operands and returns the remainder of this division operation.

main.c

#include <stdio.h>

int main() {
    int a, b, result;
    a = 38;
    b = 7;
    //remainder
    result = a % b;
    printf("Result : %d\n", result);
    return 0;
}

Output

Result : 3
Program ended with exit code: 0

Refer C Modulus tutorial.

Increment

Increment Operator ++ increments the value of the operand by one.

main.c

#include <stdio.h>

int main() {
    int a;
    a = 12;
    //increment
    a++;
    printf("Result : %d\n", a);
    return 0;
}

Output

Result : 13
Program ended with exit code: 0

Refer C Increment tutorial.

Decrement

Decrement Operator -- decrements the value of the operand by one.

main.c

#include <stdio.h>

int main() {
    int a;
    a = 12;
    //decrement
    --a;
    printf("Result : %d\n", a);
    return 0;
}

Output

Result : 11
Program ended with exit code: 0

Refer C Decrement tutorial.

Conclusion

In this C Tutorial, we learned what Arithmetic Operators are, and what they can do, with the help of example C programs.