# C Program to Perform Addition, Subtraction, Multiplication and Division

## Addition, Subtraction, Multiplication, and Division in C

To perform addition, subtraction, multiplication and division of any two number in C programming, you have to ask to the user to enter the two number and then ask to enter the operator to perform the mathematical operations.

## C Programming Code to Perform Addition, Subtraction, Multiplication and Division

Following C program ask from user to enter the two number to perform addition, subtraction, multiplication and division of the entered two numbers:

```/* C Program - Addition, Subtraction, Multiplication, and Division */

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a, b, res;
printf("Enter two number :");
scanf("%d%d",&a,&b);
res=a+b;
res=a-b;
printf("\nSubtraction = %d",res);
res=a*b;
printf("\nMultiplication = %d",res);
res=a/b;
printf("\nDivision = %d",res);
getch();
}```

When the above c program is compile and executed, it will produce the following result:

## C Programming Code to Perform Mathematical Operations

Following C program ask to the user to enter the two number along with operator to perform particular mathematical operation (addition, subtraction, multiplication and division) according to user:

```/* C Program - Mathematical Operations */

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a, b;
char ch;
printf("Enter first Number :");
scanf("%d",&a);
printf("Enter second Number :");
scanf("%d",&b);
printf("Enter operator (+, -, *, /) :");
scanf(" %c",&ch);
if(ch=='+')
printf("Result = %d",a+b);
else if(ch=='-')
printf("Result = %d",a-b);
else if(ch=='*')
printf("Result = %d",a*b);
else if(ch=='/')
printf("Result = %d",a/b);
else
printf("Wrong Operator!!!");
getch();
}```

When the above C program is compile and executed, it will produce the following result:

### Same Program in Other Programming Language

You may also like same program in other programming languages:

Tools
Calculator