C FunctionsLesson 23Free preview
C Functions
This lesson is part of C · All levels
Summary
Function is a block of code named designed to perform a specific task and can be called many times from any part of a program. Using the function makes code more modular, easier to test, and reduces duplication. A function can receive a parameter as input and return a value via the statement return. In C, a function must be declared or defined before being called in for the compiler to know it.
Key points
- The function consists of the return type, name, parameters, and blocks of the function body
- Return sends the value back to the caller and ends the function
- The void function does not return the value at all
- This structure encourages modular code and avoids duplication of logic.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.