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.