-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathCalculator
More file actions
29 lines (29 loc) · 691 Bytes
/
Calculator
File metadata and controls
29 lines (29 loc) · 691 Bytes
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
#include<iostream>
using namespace std;
int main()
{
float n1,n2;
char op,ch;
do{
cout<<"Enter first operand, operator and second operand"<<endl;
cin>>n1>>op>>n2;
switch(op)
{
case '+':
cout<<"Result of "<<n1<<"+"<<n2<<"is"<<" "<<n1+n2<<endl;
break;
case '-':
cout<<"Result of "<<n1<<"-"<<n2<<" is "<<" "<<n1-n2<<endl;
break;
case '*':
cout<<"Result of "<<n1<<"*"<<n2<<" is "<<" "<<n1*n2<<endl;
break;
case '/':
cout<<"Result of "<<n1<<"/"<<n2<<" is "<<" "<<n1/n2<<endl;
}
cout<<"Do you want to use the program again?(y/n)"<<endl;
cin>>ch;
}
while(ch!='n');
return 0;
}