# Arithmetic Operations in C programming

**Program description:**

Write a program to **perform arithmetic operations in c programming** language.

The program will take two integers as the input from the user. And then we will perform the addition, subtraction, multiplication, division, and modulus of the two integers.

**Example: Arithmetic Operations:**

**Input:**

1 |
Enter two integers : 20 10 |

**Output:**

1 2 3 4 5 |
Addition of 20 and 10 is : 30 Subtraction of 20 and 10 is : 10 Product of 20 and 10 is : 200 Division of 20 and 10 is : 2 Modulus of 20 and 10 is : 0 |

**Program : Arithmetic Operations in C:**

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
#include<stdio.h> int main(void) { int a,b; // Take input from the user. printf("Enter two integers : "); scanf("%d%d",&a, &b); // Perform all arithmetic operations. printf("Addition of %d and %d is : %d\n", a, b, a+b); printf("Subtraction of %d and %d is : %d\n", a, b, a-b); printf("Product of %d and %d is : %d\n", a, b, a*b); printf("Division of %d and %d is : %d\n", a, b, a/b); printf("Modulus of %d and %d is : %d\n", a, b, a%b); return 0; } |

Above program will take two integers from user and then uses the in-built addition operator ( ‘+’ ) to perform the sum of two integer.

Similarly we use subtraction operator ( ‘-‘ ), Multiplication operator ( ‘*’ ), Division Operator ( ‘/’ ) and Modulus Operators ( ‘%’ ) to perform remaining arithmetic operations.

We have discussed more about the arithmetic operators in the following article. Please go through it for more info

Arithmetic Operators in C Language | Examples of Arithmetic Operators – SillyCodes

**Output:**

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
// Compile the program $ gcc arithmeticOperations.c // Executable file is generated. Name of executable file is './a.out' $ ./a.out Enter two integers : 10 2 Addition of 10 and 2 is : 12 Subtraction of 10 and 2 is : 8 Product of 10 and 2 is : 20 Division of 10 and 2 is : 5 Modulus of 10 and 2 is : 0 $ // Example 2 $ ./a.out Enter two integers : 50 10 Addition of 50 and 10 is : 60 Subtraction of 50 and 10 is : 40 Product of 50 and 10 is : 500 Division of 50 and 10 is : 5 Modulus of 50 and 10 is : 0 $ // Example 3 $ ./a.out Enter two integers : 6 4 Addition of 6 and 4 is : 10 Subtraction of 6 and 4 is : 2 Product of 6 and 4 is : 24 Division of 6 and 4 is : 1 Modulus of 6 and 4 is : 2 |

**Conclusion:**

In this article, We have discussed about the arithmetic operators and how to perform arithmetic operations in the c programming language.

## 1 Response

[…] Arithmetic Operations in C programming – SillyCodes […]