-
Notifications
You must be signed in to change notification settings - Fork 0
/
scienticfic cal.cpp
162 lines (128 loc) · 3.02 KB
/
scienticfic cal.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#include <iostream>
#include <math.h>
using namespace std;
void Addition();
void Subtraction();
void Multiplication();
void Division();
void Power();
void Factorial();
void square();
void cube();
void squareroot();
int main()
{
cout<<"Welcome to the scientific Calculator , developed by.....!!\n";
cout<<"****Press 0 to quit the programing****\n ";
cout<<"Enter 1 for Addition \n" ;
cout<<"Enter 2 for Subtraction \n ";
cout<<"Enter 3 for Multiplication \n ";
cout<<"Enter 4 for Division\n ";
cout<<"Enter 5 for Power \n";
cout<<"Enter 6 for Factorial \n";
cout<<"Enter 7 for square \n";
cout<<"Enter 8 for cube\n ";
while(1){
int choice;
cout<<"Enter you choice: ";
cin>>choice;
switch(choice){
case 1:
Addition();
break;
case 2:
Subtraction();
break;
case 3:
Multiplication();
break;
case 4:
Division();
break;
case 5:
Power();
break;
case 6:
Factorial();
break;
case 7:
square();
break;
case 8:
cube();
break;
case 10:
squareroot;
break;
case 0:
exit(0);
default:
cout<<"****Wrong choice , Enter a valid choice****";
break;
}
}
return 0;
}
void Addition(){
cout<<"Enter the number (Addition):\n ";
float a,b;
cin>>a>>b;
cout<<"Sum of "<<a<<" and "<<b<<"="<<a+b<<"\n";
}
void Subtraction(){
cout<<"Enter the number (Subtraction):\n ";
float a,b;
cin>>a>>b;
cout<<"Subtraction of "<<a<<" and "<<b<<"="<<a-b<<"\n";
}
void Multiplication(){
cout<<"Enter the number (Multiplication):\n ";
float a,b;
cin>>a>>b;
cout<<"Multiplication of "<<a<<" and "<<b<<"="<<a*b<<"\n";
}
void Division(){
cout<<"Enter the number (Division):\n ";
float a,b;
cin>>a>>b;
cout<<"Division of "<<a<<" and "<<b<<"="<<a/b<<"\n";
}
void Factorial(){
// 5!=5*4*3*2*1
int n,fact=1;
cout<<"Enter the number (Factorial):\n ";
cin>>n;
for(int i=1;i<=n;i++){
fact=fact*i;
}
cout<<"Factorial of "<<n<<" is "<<fact<<"\n";
}
void Power(){
int x, y, Power;
cout << "Enter the base value: ";
cin >> x;
cout << "Enter the exponent value: ";
cin >> y;
Power=pow(x,y);
cout<<"power ="<<Power<<"\n\n";
}
void square(){
cout<<"Enter the number (square)";
double b;
cin>>b;
double power = b*b;
cout<<"The square of "<<b<<" is "<<power<<"\n\n";
}
void cube(){
cout<<"Enter the number (cube)";
double b;
cin>>b;
cout<<"Cube of"<<b<<" ="<<b*b*b<<"\n\n";
}
void squareroot(){
cout<<"Enter the number (squareroot) ";
double n;
cin>>n;
double squareroot=sqrt(n);
cout<<"The squareroot of "<<n<<squareroot<<"\n";
}