Lesson 11 of 50 · c
Functions – Declaration & Definition
Duration: 10 mins
Functions encapsulate reusable code. A prototype (declaration) tells the compiler about the function’s name, return type, and parameters before it is used.
/* Prototype */
int add(int a, int b);
int main(void) {
int sum = add(3, 4);
printf("%d\n", sum);
return 0;
}
/* Definition */
int add(int a, int b) {
return a + b;
}