C++ Program Code for Addition, Subtraction , Multiplication and Division of Numbers

Question Types:

Program code for mathematical operations using C++ programming language ?
C++ program code for addition of numbers ?
C++ program code for subtraction of numbers ?
C++ program code for multiplication of numbers ?
C++ program code for division of numbers ?

Program Code (without using functions):

#include<iostream>
using namespace std;
int main()
{
double ist , sec ,out;
char operation;
cout<<"Enter First Number : ";
cin>>ist;
cout<<"Enter mathematical operation : ";
cin>>operation;
cout<<"Enter Second Number : ";
cin>>sec;

 switch(operation)
 {
  case '+':
  out = ist + sec ;
  cout<<"Addition of Two numbers is :  "<<out;
  break;
 
  case '-':
  out = ist - sec ;
  cout<<"Subtraction of Two numbers is :  "<<out;
  break;
 
  case '*':
  out = ist * sec ;
  cout<<"Multiplication of Two numbers is :  "<<out;
  break;
 
  case '/':
  out = ist / sec ;
  cout<<"Division of Two numbers is :  "<<out;
  break;
  default:
  cout<<"Mathematical operation is invalid : ";
 }
return 0;
}

Output:

.exe file

No comments:

Post a Comment

Please disable your ad blocker to support this website.

Our website relies on revenue from ads to keep providing free content.