Function က code block တစ်ခုကို name ပေးထားတာပါ။ တစ်ခါရေးပြီး နေရာအများကြီးမှာ ပြန်ခေါ်သုံးနိုင်လို့ code repeat လျော့ပြီး project ကို ထိန်းရလွယ်စေပါတယ်။
c
#include <stdio.h>
void showWelcome() {
printf("Welcome to C functions!
");
}
int main() {
showWelcome();
showWelcome();
return 0;
}void ဆိုတာ function က value ပြန်မပေးဘူးဆိုတဲ့အဓိပ္ပါယ်ပါ။ showWelcome() ကိုခေါ်တိုင်း function ထဲက code run ပါတယ်။
You should see
Welcome to C functions! Welcome to C functions!Info
Function name ကို action အနေနဲ့ရေးတာကဖတ်ရလွယ်ပါတယ်။ ဥပမာ calculateTotal, printMenu, validateInput။