Home » C Program for Addition Subtraction Multiplication and Division using the Function

# C Program for Addition Subtraction Multiplication and Division using the Function

Learn about C Program for Addition Subtraction Multiplication and Division using the Function in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.

Contents

#### C Program for Addition Subtraction Multiplication and Division using the Function

Program:

``````#include<stdio.h>

int subtract(int n1, int n2);
int multiply(int n1, int n2);
int divide(int n1, int n2);

int main()
{
int num1, num2;

printf("Enter two numbers: ");
scanf("%d %d", &num1, &num2);

printf("%d + %d = %d\n", num1, num2, add(num1, num2));
printf("%d - %d = %d\n", num1, num2, subtract(num1, num2));
printf("%d * %d = %d\n", num1, num2, multiply(num1, num2));
printf("%d / %d = %d\n", num1, num2, divide(num1, num2));

return 0;
}

{
int result;
result = n1 + n2;
return result;
}

int subtract(int n1, int n2)
{
int result;
result = n1 - n2;
return result;
}

int multiply(int n1, int n2)
{
int result;
result = n1 * n2;
return result;
}

int divide(int n1, int n2)
{
int result;
result = n1 / n2;
return result;
}``````

Output:

Enter two numbers: 4 2
4 + 2 = 6
4 – 2 = 2
4 * 2 = 8
4 / 2 = 2

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.