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.