Repository navigation
Expand file tree
/
Copy pathFunctions.cpp
More file actions
164 lines (122 loc) · 2.46 KB
/
Copy pathFunctions.cpp
File metadata and controls
164 lines (122 loc) · 2.46 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
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
163
164
#include <iostream>
#include <typeinfo>
using namespace std;
// Greatest Number function
void GreatestNumber (int a, int b, int c){
if(a>=b && a>=c){
cout<<a<<" is the greatest number."<<endl;
}
else if(b>=a && b>=c){
cout<<b<<" is the greatest number."<<endl;
}
else if(c>=a && c>=b){
cout<<c<<" is the greatest number."<<endl;
}
}
// Counting from 1 to n
void CountTilln(int n){
for (int a=0; a<n; a++){
cout<<a+1<<endl;
}
}
//Prime Number Checking
bool PrimeNoCheck(int n){
int a;
if(n==0 || n==1){
cout<<n<<" is not a prime number"<<endl;
}
else {
for(int a=2; a<n; a++){
if(n%a==0){
cout<<n<<" is not a prime number"<<endl;
return false;
}
}
cout<<n<<" is a prime number"<<endl;
}
}
//Sum of even numbers
void SumOFEvenNo (int n){
int sum=0;
for (int a=0; a<=n; a++){
if(a%2==0){
sum+=a;
}
}
cout<<"The sum of even numbers is "<<sum<<endl;
}
int main(){
// int a=5;
// float b=10.5;
// float result1= a + (int)b;
// int result2= a + (int)b;
// int c=-100;
//unsigned int ans= (c>>1);
// cout<<(a&b)<<endl;
// cout<<(a|b)<<endl;
// bool c=-1;
// cout<<(~c)<<endl;
// cout<<(a^c)<<endl;
// cout<<(a^b)<<endl;
// cout<<ans<<endl;
// cout<<(i++)*10<<endl;
// cout<< i;
// cout<<(++b)*(b++)<<endl;
// int x = ++b;
// int y = b++;
// cout << x * y << endl;
// for (int i=0; i<5; i++){
// cout<<i<<endl;
// if(i==3)
// break;
// }
// for (int i=0; i<5; i++){
// if(i==3)
// continue;
// cout<<i<<endl;
// }
// cout<<result1<<endl;
// cout<<typeid(result1).name()<<endl;
// cout<<result2<<endl;
// cout<<b<<endl;
// int a=100;
// char ch= a;
// cout<<ch<<endl;
// // Switch case
// float a, b, ans, c=10.3;
// int op;
// cout<<"Enter any two numbers: "<<endl;
// cin>>a;
// cin>>b;
// cout<<"Operation you would like to perform: ";
// cin>>op;
// switch(op){
// case 0:
// ans= a+b;
// break;
// // c1
// case 1:
// ans= a-b;
// break;
// // c2
// case 2:
// ans= a*b;
// break;
// // c3
// case 3:
// ans= a/b;
// break;
// // default
// default:
// cout<< "Invalid Operation";
// return 0;
// }
// cout<<"Your answer is: "<<ans<<endl;
// cout<<c<<endl;
// sumofno(3,5);
// GreatestNumber(2, 7, 8);
// CountTilln(5);
// SumOFEvenNo(10);
// PrimeNoCheck(6);
return 0;
}