Write a C program to input two numbers and perform addition, subtraction, multiplication, division and modulus operations of two numbers. C program to perform all arithmetic operations of given two numbers.

Input first number: 10

Input second number: 5

Output:

Sum = 15

Difference = 5

Product = 50

Quotient = 2

Modulus = 0

Happy coding ;)

**Example:**Input first number: 10

Input second number: 5

Output:

Sum = 15

Difference = 5

Product = 50

Quotient = 2

Modulus = 0

### Required knowledge:

Fundamentals of C, Data types, Taking user input in C### Program:

/** * C program to perform addition, subtraction, multiplication, division two numbers */ #include <stdio.h> int main() { int num1, num2; int sum, sub, mult, mod; float div; /* * Read two numbers from user */ printf("Enter any two numbers : \n"); scanf("%d%d", &num1, &num2); /* * Performs all arithmetic operations */ sum = num1 + num2; sub = num1 - num2; mult = num1 * num2; div = (float)num1 / num2; mod = num1 % num2; /* * Prints the result of all arithmetic operations */ printf("SUM = %d\n", sum); printf("DIFFERENCE = %d\n", sub); printf("PRODUCT = %d\n", mult); printf("QUOTIENT = %f\n", div); printf("MODULUS = %d", mod); return 0; }

Output

Enter any two numbers :

20

10

SUM = 30

DIFFERENCE = 10

PRODUCT = 200

QUOTIENT = 2.000000

MODULUS = 0

20

10

SUM = 30

DIFFERENCE = 10

PRODUCT = 200

QUOTIENT = 2.000000

MODULUS = 0

Happy coding ;)

### You may also like

- Basic C programming exercises index.
- C program to find sum of two numbers.
- C program to find perimeter of rectangle.
- C program to find area of rectangle.
- C program to find diameter, circumference and area of circle.
- C program to convert length from meter to kilometer.
- C program to convert temperature from Celsius to Fahrenheit.
- C program to calculate power of two numbers x
^{y}. - C program to calculate square root of any number.
- C program to find third angle of triangle if two angles are given.
- C program to calculate area of equilateral triangle.
- C program to calculate total, average and percentage.
- C program to calculate Simple Interest.

Thanks for nice post.know details

ReplyDelete