-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlibx.cpp
More file actions
115 lines (99 loc) · 2.1 KB
/
Copy pathlibx.cpp
File metadata and controls
115 lines (99 loc) · 2.1 KB
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
#include <iostream>
using namespace std;
int add(int x,int y){
int z = x + y;
cout << z << endl ;
return 0;
}
int sub(int x,int y){
int z = x - y;
cout << z << endl ;
return 0;
}
int multi(int x,int y){
int z = x * y;
cout << z << endl ;
return 0;
}
int divint(int x,int y){
int z = x / y;
cout << z << endl ;
return 0;
}
float divfloat(float x,float y){
float z = x / y;
cout << z << endl ;
return 0;
}
int sq(int x){
int z = x*x;
cout << z << endl ;
return 0;
}
int cube(int x){
int z = x*x*x;
cout << z << endl ;
return 0;
}
int isdivby2(int x){
string sx = to_string(x);
char back = sx.back();
if (back == '2' || back == '4' || back == '6' || back == '8' || back == '0'){
cout << "yes" << endl ;
}else{
cout << "no" << endl ;
}
return 0;
}
int max(int x,int y){
if(x>y){
cout << x << " is greater than " << y << endl;
}else{
cout << y << " is greater than " << x << endl ;
}
return 0;
}
int min(int x,int y){
if(x<y){
cout << y << " is greater than " << x << endl ;
}else{
cout << x << " is greater than " << y << endl ;
}
return 0;
}
int max(int x,int y,int z){
if(x>y && x>z){
cout << x << " is greater than " << y << " and " << z << endl ;
}else if(y>x && y>z){
cout << y << " is greater than " << x << " and " << z << endl ;
}else{
cout << z << " is greater than " << y << " and " << x << endl ;
}
return 0;
}
int min(int x,int y,int z){
if(x<y && x<z){
cout << x << " is smaller than " << y << " and " << z << endl ;
}else if(y<x && y<z){
cout << y << " is smaller than " << x << " and " << z << endl ;
}else{
cout << z << " is smaller than " << y << " and " << x << endl ;
}
return 0;
}
int fact(int n) {
int fact = 1;
for(int i = 1 ; i <= n ; i++){
fact = fact*i;
}
cout << n << "! = " << fact << endl;
return 0;
}
int main () {
cube(5);
sq(7);
isdivby2(3);
min(2,4);
min(2,3,4);
fact(5);
}