Preview
Introduction to function in C Language
It is defined as named block of statements .
Advantages
- Easy to diagnose errors in program .
- Reduced complexity.
- Easier testing of a program .
- Functions help to divide big softwares into smaller sections.
- Reusability.
- Simple to understand .
- Efficient memory utilization.
- Reduces repetition of code.
Creating a function
The syntax for creating a function is
Type Fun_name(Parameters)
{
Variables ;
:
:
Statements;
:
:
return( Value );
}
Type is the data types of value returned by function.
Fun_name is the functions name specified by the programmer.
Parameters are variables declared within parenthesis written after the function name.
Variables are local variables declared within function body.
Statements is set of instructions which would run when function is called.
return is used to return a value from function.
Value is any valid variable, constant or expression.
Best Books of C