In C++ we have two different types of functions, which is given below:
1. Built-in functions / Library functions: These are the pre-defined set of functions which are already defined in the C++ compiler library and ready for use in the programs are known as Built-in functions or Library functions. In case we want to use these built in function in our program, simply include a reference of their prototype declaration in your program from its corresponding header file. Some examples of Built-in functions are given below:
S.No
|
Header Files
|
Built – in Functions
|
1
|
string.h
|
strlen(), strcmp(), strrev(), strchr(), strtr(), substr(), strtoupper() etc
|
2
|
math.h
|
ceil(), floor(), fabs(), log(), fmod(), sqrt(), pow() etc
|
3
|
process.h
|
execle, getpid, execlp, exit() etc
|
4
|
conio.h
|
getch(), clrscr() etc
|
5
|
stdlive.h
|
free() etc
|
6
|
dos.h
|
sound() etc
|
2. User-defined functions: A user-defined function is that function in which user can add its even special set of instructions that are not present in a build in function.
There are some steps which should be followed while creating the user-defined function in any program:
1. Every user-defined function should have a return type.
2. Each should have a name which is written according to the rules of identifiers.
3. It should take zero or more parameters.
4. Remember the sequence of types of the parameter given to the function.
Syntax of user defined functions:
return_type function_name ( argu_1,.........., argu_n);
Example:
int add( int a, int b);
float multiplication( float a, int b);
Thanks
Mukesh Rajput
Post A Comment:
0 comments: