-
Notifications
You must be signed in to change notification settings - Fork 0
/
calculator.cpp
78 lines (53 loc) · 1.1 KB
/
calculator.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include <iostream>
using namespace std;
int main()
{
while(true){
float a,b;
char ch;
cout<<"Input a number: ";
cin>>a;
cout<<"Input another number: ";
cin>>b;
cout<<"Press A for sum, M for multiplicattion, D for dividor, S for subtraction, R for remainder, P for power and C for clear : ";
cin>>ch;
switch(ch){
case 'A':
cout<<"The sum is: "<< a+b<<endl;
break;
case 'S':
cout<<"The subtraction is: "<< a-b<<endl;;
break;
case 'D':
cout<<"The dividing is: "<<a/b<<endl;;
break;
case 'M':
cout<<"The multiplication is: "<< a*b<<endl;
break;
case 'R':
cout<<"The remainder is :"<<(int)a%(int)b<<endl;
break;
case 'C':
system("cls");
break;
case 'P':
int i;
int t;
cout<<"Input power: ";
cin>>i;
for(int j=0;j<i;j++){
t=a+a*j;
}
cout<<"The power is: "<<t<<endl;
break;
default:
cout<<"Error character"<<endl;
}
cout<<"Do you want to continue: ";
cin>>ch;
if(ch=='N'){
break;
}
}
return 0;
}