-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathabhigyan1.cpp
78 lines (76 loc) · 2.73 KB
/
abhigyan1.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>
#include<cmath>
using namespace std;
class calculator{
public:
float number1;
float number2;
void basic_calculator(){
int choice;
while(1){
cout<<"Options:"<<endl;
cout<<"Click 1. To Add two numbers"<<endl;
cout<<"Click 2. To Subtract two numbers"<<endl;
cout<<"Click 3. To Multiply two numbers"<<endl;
cout<<"Click 4. To Divide two numbers"<<endl;
cout<<"Click 5. To Calculate square of a number"<<endl;
cout<<"Click 6. To Calculate square root of a number"<<endl;
cout<<"Click 7. To Calculate cube of a number"<<endl;
cout<<"Click 8. To Calculate cube root of a number"<<endl;
cout<<"Click 0. To Exit the program"<<endl;
cout<<"Enter your choice"<<endl;
cin>>choice;
if(choice==1){
cout<<"Enter the two numbers:";
cin>>number1>>number2;
cout<<"Addition of two numbers is:"<<number1+number2<<endl;
}
else if(choice==2){
cout<<"Enter the two numbers:";
cin>>number1>>number2;
cout<<"Subtraction of two numbers is:"<<number1-number2<<endl;
}
else if(choice==3){
cout<<"Enter the two numbers:";
cin>>number1>>number2;
cout<<"Multiplication of two numbers is:"<<number1*number2<<endl;
}
else if(choice==4){
cout<<"Enter the two numbers:";
cin>>number1>>number2;
cout<<"Division of two numbers is:"<<number1/number2<<endl;
}
else if(choice==5){
cout<<"Enter the number:";
cin>>number1;
cout<<"Square of the number is:"<<number1*number1<<endl;
}
else if(choice==6){
cout<<"Enter the number:";
cin>>number1;
cout<<"Square root of the number is:"<<sqrt(number1)<<endl;
}
else if(choice==7){
cout<<"Enter the number:";
cin>>number1;
cout<<"Cube of the number is:"<<number1*number1*number1<<endl;
}
else if(choice==8){
cout<<"Enter the number:";
cin>>number1;
cout<<"Cube root of the number is:"<<cbrt(number1)<<endl;
}
else if(choice==0){
break;
}
else {
cout<<"Invalid choice!"<<endl;
}
}
}
};
int main(){
calculator ca;
ca.basic_calculator();
return 0;
}