Functions Flashcards
What is Function?
Functions in C are the basic building blocks of a C program. A function is a set of statements enclosed within curly brackets ({}) that take inputs, do the computation, and provide the resultant output. You can call a function multiple times, thereby allowing reusability and modularity in C programming.
How to Declare a Function?
- function type { for ex. int,void}
- function name
- function parameters {ex. int a,int b}
Function Definition?
A Function definition. consists of function header and function body
1.function type
2.function name
3.function parameters.
4.Declaring Local Variables.
5.Function statements.
6.Return Statements
What are the components of Function Header?
- Return type
- Function Name.
- Function Parameters.
What are the components of Function body?
1.Local Variables.
2.Function Statements.
3.Return Statements
Note
1.When a function reaches its return statements, the control is transferred
back to the calling program.
2. In the absence of return statement, the closing brace acts as a void
return.
3. A local variable is a variable that is defined in the function and cannot
be used outside the function.
how to call a functions?
By function name(function parameters);