C Functions

Types of functions:

A function may belong to any one of the following categories:
1. Functions with no arguments and no return values.
2. Functions with arguments and no return values.
3. Functions with arguments and return values.

Functions with no arguments and no return values:

/* Program to illustrate a function with no argument 
   and no return values*/ 
#include 
main() 
{ 
statemetn1(); 
starline(); 
statement2(); 
starline(); 
} 
/*function to print a message*/ 
statement1() 
{ 
printf(“\n Sample subprogram output”); 
} 
statement2() 
{ 
printf(“\n Sample subprogram output two”); 
} 
starline() 
{ 
int a; 
for (a=1;a less 36;a++) 
printf(“%c”,’*’); 
printf(“\n”); 
} 

        


Explanation



In the above example there is no data transfer between the calling function and the called function. When a function has no arguments it does not receive any data from the calling function.
Similarly when it does not return value the calling function does not receive any data from the called function.
A function that does not return any value cannot be used in an expression it can be used only as independent statement.

Make Comments..!!


Oops!! No posts from user.

Download Android App