A function is a self contained block that always reduces to a single value when executed. In C there are two types of functions are available: User defined functions and predefined functions / library functions.
Predefined functions:
User Defined Functions
Functions provided by library are not enough for user so to complete their needs user has to define some functions themselves, these are called user defined functions.
To use user defined functions in C, you must declare it, you must call it, and you must define it. The following C program show a user define function is used.
Predefined functions:
The functions which are already defined in C libraries are called predefined functions or library functions. To use any predefined function in your C program, first you must include the appropriate header file and then call the library function with proper syntax. There is no to declared and define it. The declamation and definition are present in libraries itself.
For the following C program uses a power() function in 'math.h' header file
void main() { int a=5,b=3,result; result=pow(a,b); printf("result=%",result); getch(); }
User Defined Functions
Functions provided by library are not enough for user so to complete their needs user has to define some functions themselves, these are called user defined functions.
To use user defined functions in C, you must declare it, you must call it, and you must define it. The following C program show a user define function is used.
void display(); void main() { display(); getch(); } void display() { printf(" Hi, I am user defined function"); }
0 comments :
Post a Comment
Note: only a member of this blog may post a comment.