CHAPTER 15 / 26
C Functions
Learn how to create reusable blocks of code using functions.
01 — Syntax
return_type function_name() {\n // code\n}02 — Example
#include <stdio.h>
void greet() {
printf("Welcome to AIFA C Lab!");
}
int main() {
greet();
return 0;
}03 — Important Points
- Functions reduce repetition.
- Give functions one clear responsibility.
04 — Common Mistakes
- Calling a function before its declaration in code that requires a prototype.
- Using mismatched return types.
05 — Real-World Use
Functions are the basic unit of reusable logic in C programs.
06 — Practice
Create a small program that demonstrates the main idea of C Functions.