# C Program to Perform All Arithmetic Operations

Hello coders, in this post we will how to write C Program to perform all arithmetic operations. This is a very basic C program.

As you already know that this site does not contain only c programming solutions here, you can also find the solution for other problems. I.e.Â Web Technology,Â Data Structures,Â RDBMS Programs,Â Java Programs Solutions, Â Fiverr Skills Test answers,Â Google Course Answers,Â Linkedin Assessment,Â Leetcode Solutions, andÂ Coursera Quiz Answers.

if you want to learn C programming free of cost please visit:

## C Program to perform all arithmetic operations

```#include <stdio.h>

void main()
{
int num1, num2;
int sum, diff, mul, div, mod, quo;

printf("Enter first number: ");
scanf("%d", &num1);
printf("Enter second number: ");
scanf("%d", &num2);

sum = num1 + num2;
diff = num1 - num2;
mul = num1 * num2;
mod = num1 % num2;
quo = num1 / num2;

printf("Sum = %d\n", sum);
printf("Difference = %d\n", diff);
printf("Multiply = %d\n", mul);
printf("Modulus = %d\n", mod);
printf("Quotient = %d\n", quo);
}```

Output

```Enter first number: 30
Enter second number: 10
Sum = 40
Difference = 20
Multiply = 300
Modulus = 0
Quotient = 3```

### C Program to perform all arithmetic operations using function

```// C Program to Perform Arithmetic Operations Using Functions
#include <stdio.h>

int sum = a + b;
return sum;
}

// Declaring subtraction function
int subtract(int a, int b){
int difference = a - b;
return difference;
}

// Declaring multiplication function
int multiply(int a, int b){
int multiply = a * b;
return multiply;
}

// Declaring division function
float division(float a, float b){
float divide = a / b;
return divide;
}

// Declaring modulus function
float mod(int a, int b){
int rem = a % b;
return rem;
}

int main(){
int num1, num2;

printf("Enter the first number: ");
scanf("%d", &num1);
printf("Enter the second number: ");
scanf("%d", &num2);

// Displaying output
printf("Arithmetic operations on %d and %d: \n", num1, num2);
printf("Subtraction: %d\n", subtract(num1, num2));
printf("Multiplication: %d\n", multiply(num1, num2));
printf("Division: %f\n", division(num1, num2));
printf("Modulus: %d\n", mod(num1, num2));
return 0;
}```
```Enter the first number: 20
Enter the second number: 10
Arithmetic operations on 20 and 10: