Repository navigation
Expand file tree
/
Copy pathLecture8.cpp
More file actions
224 lines (183 loc) · 5.21 KB
/
Copy pathLecture8.cpp
File metadata and controls
224 lines (183 loc) · 5.21 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
// #include<iostream>
// using namespace std;
// // FUNCTIONS
// int setbit_number(int a , int b){
// int count = 0;
// int num = 0;
// while(a!=0){
// count += a&1;
// a = a>>1;
// }
// while(b!=0){
// num+=b&1;
// b = b>>1;
// }
// cout<<(count+num);
// return (count+num);
// }
// void AP(int n){
// int value = (3*n)+7;
// cout<< value;
// }
// void fibbo(int n)
// {
// int a=0 , b=1 , c;
// cout<<a<<" "<<b<<" ";
// for(int i=1 ; i<n-1 ; i++)
// {
// c=a+b;
// cout<<c<<" ";
// a=b;
// b=c;
// }
// }
// bool Isprime(int n){
// for(int i = 2; i<n; i++){
// if(n%i==0){
// return 0;
// }
// }
// return 1;
// }
// void oddeven(int a){
// if(a%2==0){
// cout<<"the number is even "<<endl;
// }
// else{
// cout<<"the number is odd "<<endl;
// }
// }
// int factorial(int n){
// int fact = 1;
// for(int i=1; i<=n; i++){
// fact = fact*i;
// }
// return fact;
// }
// int nCr(int n , int r){
// int ans = factorial(n)/(factorial(r)*factorial(n-r));
// return ans;
// }
// int power(int a, int b){
// int ans = 1;
// for(int i=0; i<b; i++){
// ans = ans*2;
// }
// return ans;
// }
// int main(){
// -------::::::::::::::::::::SWITCH CASES::::::::::::::::::::--------
// int num = 1;
// switch(num){
// case 1: cout<<"first"<<endl;
// break; // break is used to exit the switch loop if i do not use it then next all statement will print.
// case 2: cout<<"second"<<endl;
// break;
// default: cout<<"default"<<endl;
// }
// :::::::::::::::CALCULATOR::::::::::::::::
// int a;
// cout<<"enter the value of a :"<<endl;
// cin>>a;
// int b;
// cout<<"enter the value of b :"<<endl;
// cin>>b;
// char op;
// cout<<"enter the operation :"<<endl;
// cin>>op;
// switch(op){
// case '+': cout<<(a+b)<<endl;
// break;
// case '-': cout<<(a-b)<<endl;
// break;
// case '*': cout<<(a*b)<<endl;
// break;
// case '/': cout<<(a/b)<<endl;
// break;
// default : cout<<"the operation is not valid "<<endl;
// }
// return 0;
// :::::::::::::NUMBER OF NOTES REQUIRED:::::::::::::
// int amount;
// cout<<"Enter the Amount : "<<endl;
// cin>>amount;
// int note = 0;
// switch (1){
// case 1: {
// note = amount/100;
// cout<<note<<" Rs.100 notes requied."<<endl;
// amount = amount - (100 * note);
// }
// case 2:{
// note = amount/50;
// cout<<note<<" Rs.50 notes requied."<<endl;
// amount = amount - (50 * note);
// }
// case 3:{
// note = amount/20;
// cout<<note<<" Rs.20 notes requied."<<endl;
// amount = amount - (20 * note);
// }
// case 4:{
// note = amount/1;
// cout<<note<<" Rs.1 notes requied."<<endl;
// amount = amount - (1 * note);
// }
// return 0;
// }
// USES OF FUNCTIONS
// int num1 , num2;
// cin>>num1>>num2;
// int ans = power(num1,num2);
// cout<<"Answer is : "<<ans<<endl;
// return 0;
// int a;
// cin>>a;
// oddeven(a);
// return 0;
// int n,r;
// cin>>n>>r;
// cout<<nCr(n,r)<<endl;
// return 0;
// PRIME NUMBER OR NOT
// int n;
// cin>>n;
// if(Isprime(n)){
// cout<<"is prime number"<<endl;
// }
// cout<<"is not a prime number"<<endl;
// FIBONACCI SERIES
// int n;
// cin>>n;
// fibbo(n);
// int n;
// cin>>n;
// AP(n);
// SETBIT NUMBERS
// int a , b;
// cin>>a>>b;
// setbit_number(a,b);
//}
// int main(){
// int n,m;
// cin>>n;
// cout<<"enter the note"<<endl;
// cin>>m;
// switch(m){
// case 100: cout<<"number of 100 notes are "<<endl;
// int ans1 = n/100;
// cout<<ans1<<endl;
// break;
// case 50: cout<<"number of 100 notes are "<<endl;
// int ans2 = n-ans1*100;
// int ans21 = ans2/50;
// cout<<ans21<<endl;
// break;
// case 20: cout<<"number of 100 notes are "<<endl;
// int ans3 = n-ans1*100;
// int ans31 = ans3/30;
// cout<<ans31<<endl;
// break;
// }
// return 0;
// }