-
Notifications
You must be signed in to change notification settings - Fork 0
/
100.cpp
39 lines (32 loc) · 959 Bytes
/
100.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// C++ Program to Make a Simple Calculator to Add,Subtract,Multiply or Divide Using Swich Case.
#include<iostream>
using namespace std;
int main()
{
char opr;
float num1, num2;
cout<< "Enter Operator:- " << endl << "| + | - | * | / |: ";
cin>> opr;
cout<< "Enter Two Operands: " << endl;
cin>> num1 >> num2;
switch(opr)
{
case '+':
cout<< num1 << " + " << num2 << " = " << num1 + num2;
break;
case '-':
cout<< num1 << " - " << num2 << " = " << num1 - num2;
break;
case '*':
cout<< num1 << " * " << num2 << " = " << num1 * num2;
break;
case '/':
cout<< num1 << " / " << num2 << " = " << num1 / num2;
break;
default:
// If the operator is other than +, -, * or /, error message is shown
cout<< "Error! Operator is not Correct";
break;
}
return 0;
}