Lesson 11 of 50
cFunctions – Declaration & Definition
10 mins
Course progress22%
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 11 of 50
c10 mins
Keep these ideas in mind as you work through the lesson.
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
", sum);
return 0;
}
/* Definition */
int add(int a, int b) {
return a + b;
}