C++ Program to perform Arithmetic Operations

C++ Program to perform Arithmetic Operations

How can we make a calculator in C++? Here we are using arithmetic operators to calculate and "cout" method to print the result.

Addition of two numbers in C++ :


#include <iostream> using namespace std; int main() { int num1,num2,add,sub,multi,div,mod; cout << "Please Enter the First Value : "; cin >> num1; cout << "Please Enter the Second Value : "; cin >> num2; add = num1 + num2; sub = num1 - num2; multi = num1 * num2; div = num1 / num2; mod = num1 % num2; cout << "The Summation of "<< num1 << " and " << num2 <<" : " << add << endl; cout << "The Subtraction of "<< num1 << " and " << num2 <<" : " << sub << endl; cout << "The Multiplication of "<< num1 << " and " << num2 <<" : " << multi << endl; cout << "The Division of "<< num1 << " and " << num2 <<" : " << div << endl; cout << "The Modulus of "<< num1 << " and " << num2 <<" : " << mod << endl; return 0; }

Output :