To perform addition, subtraction, multiplication, and division of any two numbers 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 particular mathematical operation (addition, subtraction, multiplication, and division) and display the result on the screen.
C++ Program to do Addition,subtraction and multiplication of two numbers using function
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
int num1,num2;
cout << "Enter two numbers" << endl;
cin>>num1>>num2;
cout<<"\nAddition of"<<num1<<"+"<<num2<<" = "<<num1+num2;
cout<<"\nSubtraction of"<<num1<<"-"<<num2<<" = "<<num1-num2;
cout<<"\nMultiplication of"<<num1<<"*"<<num2<<" = "<<num1*num2;
cout<<"\nDivision of"<<num1<<"/"<<num2<<" = "<<num1/num2;
getch();
return 0;
}
Output of Program
Enter two numbers
5
9
Addition of5+9 = 14
Subtraction of5-9 = -4
Multiplication of5*9 = 45
Division of5/9 = 0