# Arithmetic Operators in C

Blog Contents

## Arithmetic Operators in C

These operators give the ability to do the arithmetical operations like

By using this operator it will allow the user to add two or more operands and to get the sum.
Ex: Please consider the bellow mentioned program
#include<stdio.h> // Preprocessor to include the stdio.h
int main()
// Main function which will return integer value
// Starting of the program/ function
int a=10;
// Initializing the variables a,b and declaring variable c
int b=20;
printf(“Addition of the two numbers is c=%d\n”,c);
// Subtraction of a from b
printf(“Difference of the two numbers is c=%d\n”,c);
//Product of a and b
printf(“Product of the two numbers is c=%d\n”,c);
//Dividing b by a
printf(“Division of the two numbers is c=%d\n”,c);
// finding the modulus of b by a
printf(“Modulus of the two numbers is c=%d\n”,c);
printf(“Pre-increment of the two numbers is ++a=%d\n”,++a); //Pre-incrementing the value by 1
printf(“Pre-decrement of the two numbers is –a=%d\n”,–a); // Pre-decrementing the value by 1
printf(“Post-increment of the two numbers is a++=%d\n”,a++); // Post-incrementing the value by 1
printf(“Post-decrement of the two numbers is a–=%d\n”,a–); // Post-decrementing the value by 1
return 0;
Addition of the two numbers is c=30
Difference of the two numbers is c=10
Product of the two numbers is c=200
Division of the two numbers is c=2
Modulus of the two numbers is c=0
Pre-increment of the two numbers is ++a=11
Pre-decrement of the two numbers is –a=10
Post-increment of the two numbers is a++=10
Post-decrement of the two numbers is a–=11

### Explanation :

In the above program we are trying to explain the working of arithmetic operators. There are 7 diffent types of arithmetic operators.
In this program after including the standard input /output header file to the program by using #include preprocessor, we are initializing the variables a,b and declaring the variable C. All these variables are integer data types. Next line onwards we are executing the operation.

Adding the two values which are stored in the two variables a and b and saving the sum value to variable c. Using printf function we printing the value on the console (output screen).

#### Subtraction:

We are finding the difference between two values which are stored in the two variables a and b saving the difference value to variable c. Using printf function we printing the value on the console (output screen).

#### Division:

Dividing one value with another which are stored in the two variables a and b and saving the quotient value to variable c. Using printf function we printing the value on the console (output screen).

#### Modulus:

Dividing one value with another which are stored in the two variables a and b and saving the remainder value to variable c. Using printf function we printing the value on the console output screen)

#### Pre-increment:

This increment operator first increments the value stored in variable ‘ a’ by 1 and store it back in the same variable.

#### Pre-decrement:

This decrement operator first decrements the value stored in variable ’ a’ by 1 and store it back in the same variable.

#### Post-increment:

This increment operator increments the value stored in the variable ‘a’ by 1 and stores it back in the same variable. But it will get in effect in the next instruction only.

#### Post-decrement:

This decrement operator increments the value stored in the variable ‘a’ by 1 and stores it back in the same variable. But it will get in effect in the next instruction only.
After the execution of the program, it will return 0 back to the main function (Because we used int main (), the return type of main() is an integer type only).