In this program, we will implement basic arithmetic operations using functions. We will use function dedicated to calculate the required arithmetic operation and we will call that function when we want to perform particular mathematic operation.

**Pre-requisites:**

Functions, input output functions, variables, data types

**Approach:**

We will take input from user and then pass that value to arithmetic function we have defined in our program. After that function will do expression evaluation and then will return output or we can print output in that function only.

**Step by step procedure:**

Declare a function above main method with proper prototype.

Letâ€™s take two input values from user through command prompt and store it in variable. E.g. input = 5, 6

Make function call and then pass arguments

Store results returned by function into variable or directly print output from function itself.

## Program:

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 |
/*Integer arithmetic operations in c*/ #include<stdio.h> void add(int, int); void subtract(int, int); void multiply(int, int); void divide(int, int); int main() { int a=20,b=8; add(20,8); multiply(20,8); subtract(20,8); divide(20,8); return 0; } void add(int x, int y) { printf("Sum=%d\n",x+y); } void subtract(int x, int y) { printf("Difference=%d\n",x-y); } void multiply(int x, int y) { printf("Product=%d\n",x*y); } void divide(int x, int y) { printf("Quotient=%d\n",x/y); } |

### Output:

1 2 3 4 |
Sum=28 Product=160 Difference=12 Quotient=2 |

## 1 thought on “C program to perform arithmetic operation using function”