-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path35_Example1.cpp
More file actions
41 lines (35 loc) · 885 Bytes
/
35_Example1.cpp
File metadata and controls
41 lines (35 loc) · 885 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
30
31
32
33
34
35
36
37
38
39
40
41
#include <iostream>
#include <math.h>
using namespace std;
//Calculator with 3 operation: (a^2,[a],a%b), using switch statements.
int main(){
int op;
cout << "Enter the operation: " << endl;
cin >> op; //^ => 1, [] => 2, % => 3
switch(op){
case 1: {
float n;
cout << "Enter the number: " << endl;
cin >> n;
cout << n*n;
}
break;
case 2: {
float n;
cout << "Enter the number: " << endl;
cin >> n;
cout << floor(n);
}
break;
case 3: {
int n;
int m;
cout << "Enter the numbers: " << endl;
cin >> n;
cin >> m;
cout << n%m;
}
break;
default: cout << "Wrong Input" << endl;
}
}