|
59 | 59 | // return 0;
|
60 | 60 | // }
|
61 | 61 |
|
62 |
| - |
63 | 62 | // #include <stdio.h>
|
64 | 63 | // #include <math.h>
|
65 | 64 |
|
|
85 | 84 | // float rectangle_f(float a , float b){
|
86 | 85 | // return a*b ;
|
87 | 86 | // }
|
88 |
| -// ===================================== // ====================== |
89 |
| - |
90 |
| - |
| 87 | +// ===================================== // ====================== |
91 | 88 |
|
92 | 89 | // ============================================================
|
93 | 90 | // 📌 Practice Problems
|
94 | 91 | // Topic : C Programming - Functions
|
95 |
| -// Level : 1 – Basic Function Problems |
| 92 | +// Level : 1 – Basic Function Problems |
96 | 93 | // ============================================================
|
97 | 94 |
|
98 |
| - |
99 | 95 | // ============================================================
|
100 | 96 | // 👉👉 🔹 Q-4: একটি ফাংশন লিখো যা একটি পূর্ণসংখ্যা ইনপুট নিয়ে তার স্কয়ার রিটার্ন করবে।
|
101 | 97 | // ============================================================
|
102 | 98 |
|
103 |
| - |
104 |
| - |
105 |
| - |
106 | 99 | // #include <stdio.h>
|
107 | 100 | // int square (int n);
|
108 | 101 | // int main(){
|
|
117 | 110 | // return n*n ;
|
118 | 111 | // }
|
119 | 112 |
|
120 |
| - |
121 |
| - |
122 | 113 | // ============================================================
|
123 | 114 | // 👉👉 🔹 Q-: একটি ফাংশন লিখো যা একটি পূর্ণসংখ্যা ইনপুট নিয়ে তার স্কয়ার রিটার্ন করবে।
|
124 | 115 | // ============================================================
|
|
129 | 120 | // printf("Enter Number : ");
|
130 | 121 | // scanf("%d" , &n);
|
131 | 122 | // int result = input_square(n);
|
132 |
| -// printf("Square number is : %d\n", result) ; |
| 123 | +// printf("Square number is : %d\n", result) ; |
133 | 124 | // return 0;
|
134 | 125 | // }
|
135 | 126 |
|
136 | 127 | // int input_square(int n){
|
137 | 128 | // return n*n ;
|
138 | 129 | // }
|
139 | 130 |
|
140 |
| - |
141 |
| - |
142 | 131 | // ============================================================
|
143 | 132 | // 👉👉 🔹 Q- 5: একটি ফাংশন লিখো যা একটি পূর্ণসংখ্যা ইনপুট নিয়ে বলে দেবে সংখ্যাটি জোড় না বিজোড়।
|
144 | 133 | // ============================================================
|
|
161 | 150 | // }else{
|
162 | 151 | // printf("%d is Odd.\n " , n) ;
|
163 | 152 | // }
|
164 |
| - |
165 |
| -// } |
166 | 153 |
|
| 154 | +// } |
167 | 155 |
|
168 | 156 | // ===========================================================
|
169 |
| -// 📌 Review Solve |
| 157 | +// 📌 Review Solve |
170 | 158 | // 👉👉 🔹 Q- 5: একটি ফাংশন লিখো যা একটি পূর্ণসংখ্যা ইনপুট নিয়ে বলে দেবে সংখ্যাটি জোড় না বিজোড়।
|
171 | 159 | // ============================================================
|
172 | 160 |
|
|
187 | 175 | // }else{
|
188 | 176 | // printf("%d is Odd.\n" , n);
|
189 | 177 | // }
|
190 |
| - |
191 |
| - |
192 |
| -// } |
193 | 178 |
|
| 179 | +// } |
194 | 180 |
|
195 | 181 | // ============================================================
|
196 | 182 | // 📌 Sum of Two Numbers
|
197 | 183 | // 👉👉 🔹 Q- 6: দুটি সংখ্যার যোগফল বের করার জন্য একটি ফাংশন লিখো।
|
198 | 184 | // ============================================================
|
199 | 185 |
|
200 |
| - |
201 | 186 | // #include <stdio.h>
|
202 | 187 | // int sum(int y, int z);
|
203 | 188 |
|
|
209 | 194 | // int result = sum(y,z) ;
|
210 | 195 | // printf("Result is : %d\n", result);
|
211 | 196 |
|
212 |
| - |
213 | 197 | // return 0;
|
214 | 198 |
|
215 | 199 | // }
|
|
219 | 203 | // ============================================================
|
220 | 204 | // 📌 Sum of Two Numbers
|
221 | 205 | // 👉👉 🔹 Q- 6.2: দুটি সংখ্যার যোগফল বের করার জন্য একটি ফাংশন লিখো।
|
222 |
| -// 👉 🔹 Version :2.0 |
| 206 | +// 👉 🔹 Version :2.0 |
223 | 207 | // ============================================================
|
224 | 208 | // #include <stdio.h>
|
225 | 209 | // int sum(int a , int b);
|
|
231 | 215 | // printf("Enter second Numbers : ");
|
232 | 216 | // scanf("%d", &b);
|
233 | 217 |
|
234 |
| - |
235 | 218 | // int total= sum(a,b);
|
236 | 219 | // printf("Sum is : %d\n", total);
|
237 | 220 |
|
|
242 | 225 | // return a + b ;
|
243 | 226 | // }
|
244 | 227 |
|
245 |
| - |
246 | 228 | // ============================================================
|
247 | 229 | // 📌 Practice Problems
|
248 | 230 | // Topic : C Programming - Functions
|
249 |
| -// Level 2 – Intermediate Function Problems |
| 231 | +// Level 2 – Intermediate Function Problems |
250 | 232 | // ============================================================
|
251 | 233 |
|
252 |
| - |
253 |
| - |
254 | 234 | // // ============================================================
|
255 | 235 | // 📌 Factorial Finder
|
256 |
| -// 👉👉 🔹 Q- 6: একটি ফাংশন লিখো যা একটি সংখ্যা ইনপুট নিয়ে তার Factorial বের করবে। |
| 236 | +// 👉👉 🔹 Q- 7: একটি ফাংশন লিখো যা একটি সংখ্যা ইনপুট নিয়ে তার Factorial বের করবে। |
257 | 237 | // ============================================================
|
258 | 238 |
|
259 |
| - |
260 | 239 | #include <stdio.h>
|
261 | 240 | int factorial(int n);
|
262 |
| -int main(){ |
| 241 | +int main() |
| 242 | +{ |
263 | 243 | int n;
|
264 | 244 | printf("Enter Number : ");
|
265 |
| - scanf("%d" , &n); |
266 |
| - int result = factorial(n) ; |
267 |
| - int fac = 1 ; |
268 |
| - for(int i = 1 ; i<=n ;i++){ |
269 |
| - fac = i*result; |
270 |
| - printf("FActorial is : %d\n" , result) ; |
| 245 | + scanf("%d", &n); |
| 246 | + int result = factorial(n); |
| 247 | + int fac = 1; |
| 248 | + for (int i = 1; i <= n; i++) |
| 249 | + { |
| 250 | + fac = i * fac; |
| 251 | + printf("Factorial is : %d\n", result); |
271 | 252 | }
|
272 | 253 |
|
273 | 254 | return 0;
|
274 | 255 | }
|
275 | 256 |
|
276 |
| -int factorial(int n){ |
277 |
| - return n ; |
| 257 | +int factorial(int n) |
| 258 | +{ |
| 259 | + return n; |
278 | 260 | }
|
279 | 261 |
|
280 |
| - |
281 | 262 | // #include <stdio.h>
|
282 | 263 | // int main(){
|
283 | 264 |
|
|
0 commit comments