Arithmetic Operators in C

Operators that are used for all the arithmetic operations are listed below.

OperatorMeaningDescription
+Addition or Binary PlusThis Operator is used for the addition of variables
Subtraction or Binary MinusUsed for Subtraction or variables
*MultiplicationUsed for Multiplication of Variables
/DivisionUsed for the division of two variables
%Modulo Division (Remainder)This gives us a result as a remainder. This can not be applied to floating point data
Arithmetic Operators in C

Examples:

#include <stdio.h>

int main(){
    // variable declaration and initialization
    int x = 10;
    int y = 20;
    int z = 21;
    int a,s,m,d,r;
    // example of addition, subtraction, multiplication, division and modulo
    a = x + y;
    s = y - x;
    m = x * y;
    // this is integer division
    d = z / y;
    r = z % y;

    printf("x + y = %d\n", a);
    printf("y - x = %d\n", s);
    printf("x * y = %d\n", m);
    printf("z / y = %d\n", d);
    printf("z %% y = %d\n", r); // notice %% to print %
    return 0;
}

Expected Output:

x + y = 30
y - x = 10
x * y = 200
z / y = 1
z % y = 1