• Home
  • Arithmetic Operators in C Language

Arithmetic Operators in C Language

In C, arithmetic operators are used to perform arithmetic calculations, such as addition, subtraction, multiplication, and division. The following are the arithmetic operators in C:

    • (addition): The + operator is used to add two numbers. For example:
int a = 5; 
int b = 2;
int c = a + b; // c is now 7
    • (subtraction): The – operator is used to subtract one number from another. For example:
int a = 5;
int b = 2;
int c = a - b; // c is now 3
    • (multiplication): The * operator is used to multiply two numbers. For example:
int a = 5;
int b = 2;
int c = a * b; // c is now 10
  1. / (division): The / operator is used to divide one number by another. For example:
int a = 5;
int b = 2;
int c = a / b; // c is now 2
  1. % (modulus): The % operator is used to find the remainder of a division. For example:
int a = 5;
int b = 2;
int c = a % b; // c is now 1

It is important to use the correct arithmetic operator based on the type of calculation you want to perform. Using the wrong operator can result in errors or unexpected results in your code.