C++ program for addition, subtraction, multiplication and division has been shown here. These are the basic arithmetic operations.

#### Page content(s):

1. Program & Output

2. Program & Output: Using pointers

1. Algorithm

2. Pseudocode

3. Time Complexity

4. Flowchart

## 1. C++ Program & output to Perform Addition, Subtraction, Multiplication & Division

Code has been copied
/*****************************************************************
alphabetacoder.com
C++ program for addition, subtraction, multiplication and division
*****************************************************************/

#include<iostream>

using namespace std;

int main(){
// declare variables
double a, b, w, x, y, z;

// take input
cout<<"Enter first number: ";
cin >> a;
cout<<"Enter second number: ";
cin >> b;

// compute operations
w = a + b;
x = a - b;
y = a * b;
z = a / b;

// display result
cout<<"Subtraction: "<<x<<endl;
cout<<"Multiplication: "<<y<<endl;
cout<<"Division: "<<z<<endl;

return 0;
}


Output

Enter first number: 15

Enter second number: 2.5

Subtraction: 12.5

Multiplication: 37.5

Division: 6

## 2. C++ Program & output to Perform Addition, Subtraction, Multiplication & Division using pointers

Code has been copied
/*****************************************************************************
alphabetacoder.com
C++ program for addition, subtraction, multiplication and division using pointers
*******************************************************************************/

#include<iostream>

using namespace std;

int main(){
// declare variables
double a, b, w, x, y, z, *n1, *n2;

// take input
cout<<"Enter first number: ";
cin >> a;
cout<<"Enter second number: ";
cin >> b;

//store the address in pointer
n1 = &a;
n2 = &b;

// compute operations
w = *n1 + *n2;
x = *n1 - *n2;
y = *n1 * *n2;
z = *n1 / *n2;

// display result
cout<<"Subtraction: "<<x<<endl;
cout<<"Multiplication: "<<y<<endl;
cout<<"Division: "<<z<<endl;

return 0;
}


Output

Enter first number: 15

Enter second number: 2.5

Subtraction: 12.5

Multiplication: 37.5

Division: 6