C++ Program to Perform all Arithmetic Calculation using Switch Case

Hi,We make a C++ Program to perform all arithmetic calculation using switch case it is Simple Try To make it.

C++ Program to Perform all Arithmetic Calculation using Switch Case

#include <iostream>
#include<conio.h>
using namespace std;
int main()
{
char op;
float num1, num2;
cout << "Enter operator Either + or - or * or /: ";
cin >> op;
cout << "Enter two operands: ";
cin >> num1 >> num2;
switch(op)
{
case '+':
cout << num1+num2;
break;

case '-':
cout << num1-num2;
break;

case '*':
cout << num1*num2;
break;

case '/':
cout << num1/num2;
break;

default:
// If the operator is other than +, -, * or /, error message is shown
cout << "Error! operator is not correct";
break;
}

return 0;
}

Output of Program

C++ Program to Perform all Arithmetic Calculation using Switch Case C++ Program to Perform all Arithmetic Calculation using Switch Case