C FUNCTIONS
C FUNCTIONS
Library system functions are defined inside the header files like
stdio.h, conio.h, math.h, string.h etc.
For example, the funtions printf() and scanf() are defined in the
header file called stdio.h.
Function Declaration
returnType functionName(parametersList);
Function Definition
returnType functionName(parametersList)
{
Actual code...
Function Call
The function call tells the compiler when to execute the function
definition.
When a function call is executed, the execution control jumps to the
function definition where the actual code gets executed and returns
to the same functions call once the execution completes. The
function call is performed inside main function or inside any other
function or inside the function itself.
functionName(parameters);
#include <stdio.h>
void main(){
int num1, num2, result ;
int addition(int,int) ; // function declaration
Based on the data flow between the calling function and called
function, functions are classified as follows
Function without Parameters and without Return value
Function with Parameters and without Return value
Function without Parameters and with Return value
Function with Parameters and with Return value
#include <stdio.h>
void main(){
void addition() ; // function declaration
#include <stdio.h>
void main(){
int num1, num2 ;
void addition(int, int) ; // function declaration
getch() ;
}
void addition(int a, int b) // function definition
{
printf("Sum = %d", a+b ) ;
}
#include <stdio.h>
void main(){
int result ;
int addition() ; // function declaration
#include <stdio.h>
void main(){
int num1, num2, result ;
int addition(int, int) ; // function declaration
Exercise