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 పద్ధతిలో int gcd(int a, int b) function రాయండి. 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.