Lesson 14 of 23

Functions

10 min 25 XP

Function হলো return type, নাম এবং parameters সহ নাম দেওয়া কোডের block। একে main()-এর নিচে define করলে main()-এর ওপরে একটি prototype declare করুন।

Example: edit me and press Run

Output Loading C (first time takes a few seconds)
Press Run to see the result here.

C arguments value হিসেবে পাঠায়: function-এর ভেতরে parameter বদলালে caller-এর variable বদলায় না। বদলাতে pointers লাগে (পরের module)।

Example: edit me and press Run

Output Loading C (first time takes a few seconds)
Press Run to see the result here.

Challenge

+25 XP

Euclid-এর পদ্ধতিতে function int gcd(int a, int b) লিখুন। main()-এ a ও b পড়ে GCD ও LCM print করুন। Input: 12 18 Output: GCD: 6 LCM: 36

Output Loading C (first time takes a few seconds)
Press Run to see the result here.