# Division in c++ – C++ Program to Perform Addition Subtraction Multiplication Division

Division in c++: In the previous article, we have discussedÂ C++ Program for Input and Output of Integer. In this article, we will see C++ Program to Perform Addition Subtraction Multiplication Division.

## C++ Program to Perform Addition Subtraction Multiplication Division

• Write a C++ program to add, subtract, multiply and divide two numbers.
• C++ program to perform arithmetic operations.

In this program, we will learn about basic arithmetic operators in C++ programming language.

Arithmetic operators in C++ are used to perform mathematical operations. There are five fundamental arithmetic operators supported by C++ language, which are addition(+), subtraction(-), division(/), multiplication(-), and modulus(%) of two numbers.

Operator Description Syntax Example
+ Adds two numbers a + b 15 + 5 = 20
Subtracts two numbers a – b 15 – 5 = 10
* Multiplies two numbers a * b 15 * 5 = 75
/ Divides numerator by denominator a / b 15 / 5 = 3
% Returns remainder after an integer division a % b 15 % 5 = 0

### C++ Program to Perform Addition Subtraction Multiplication Division of Two Numbers

// C++ Program for Addition, Subtraction, Multiplication, Division
// and Modulus of two numbers

#include <iostream>
using namespace std;

int main(){
/* Variable declation */
int x, y;
int sum, difference, product, modulo;
float quotient;

// Taking input from user and storing it
// in x and y
cout << "Enter First Number\n";
cin >> x;
cout << "Enter Second Number\n";
cin >> y;

sum = x + y;
// Subtracting two numbers
difference = x - y;
// Multiplying two numbers
product = x * y;
// Dividing two numbers by typecasting one operand to float
quotient = (float)x / y;
// returns remainder of after an integer division
modulo = x % y;

cout << "\nSum = " << sum;
cout << "\nDifference  = " <<difference;
cout << "\nMultiplication = " << product;
cout << "\nDivision = " << quotient;
cout << "\nRemainder = " << modulo;

return 0;
}

Output

Enter First Number
8
Enter Second Number
4

Sum = 12
Difference  = 4
Multiplication = 32
Division = 2
Remainder = 0


In above program, we first take two numbers as input from user using cin and store it in variable x and y. Then we perform Addition, Subtraction, Multiplication, Division and Modulus on operands x and y and store the result in variable sum, difference, product, quotient and modulo respectively.

Print Hello World, Multiply two Numbers, Add Two Numbers, etc. are some of the basic-level Programs in C++. Want to practice advanced C++ Programs? Go with the available links & gain more coding knowledge.