in this class we are going to discuss about types of functions in C language in C language functions are mainly classified into two types first one is
- library functions
- user defined
library functions
functions let's see the first one library functions or predefined functions library functions are already defined in the corresponding header file so library functions are already defined in the corresponding header file these functions are also known as predefined functions so those functions are already defined in the corresponding header file our compiler .
user defined functions
second one is user defined functions the name itself specifies the meaning the functions
which are defined by the user .so let's see the first one so what is library functions .so we have various library functions available in C like this..
let's see those functions one by one..... first function
printf()
scanf()
getchar()
putchar()
gets()
puts()
clrscr()
strlen()
strcpy()
strrev()
strcmp()
strcat()
sqrt()
pow()
malloc()
calloc()
realloc()
free()
function we have several laibrairy functions printf() ,scanf() getchar,putchar,gets() puts() all these functions are available in stdio.h .stdio.h stand for standard input out put.
clrscr() available in conio.h header file.conio.h stand for console input and output.
Here console means it may be either keyboard or monitor .Remaining functions are are function strlen() ,strcpy(), strrev(), strcmp() ,strcat() these functions are available in string. h . Next function we have several mathematical functions like that sqrt() ,pow() function sine function cos function tan function all these functions are available in math .h and math Stand for mathematical functions .Remaning function malloc() ,calloc(),realloc(),free() function all these functions available in the alloc.h file.alloc stand for allocation .
Advantages of all those functions
Let's see the advantages of all those functions one by one so the frist one is
getchar() function it is useful to read a single character from the keyboard so if
you want to read a number or if you want to read a string then it is very difficult to read the data with the help of getchar() function and the second one
is scanf() of function it is useful to read different types of data such as members characters and strings from the keyboard next one is gets function it is useful to read a string which contains blank space also .The next one is putchar() function it is useful to print
a single character next one printf() function it is useful to display different types of data such as characters numbers and strings on the monitor next one is puts() function it is
useful to display a string on the monitor next one Clrscr() stands for clearing the screen it is useful to clear the output screen next one is STRlen() it is useful to calculate length of your string next one strcpy() it is useful to copy the context of one string to another string
next one STRrev() it is useful to reverse the given string next one strcmp() it is useful to compare two strings next one Strcat() it is useful to concatenate those things all these string manipulation functions are available in string header file .Next one sqrt() it is useful to calculate square root of a given nimble next one pow() it is useful to calculate power of a given number next malloc() and calloc() functions by using these two functions we can allocate memory to a pointer variable during runtime that is execution time next one realloc() function it is useful to change the size of previously allocated memory block so we can increase the size as well as we can decrease the size of the allocated memory .Last one is free() function it is useful to free the memory which is already allocated by malloc() or Clrscr() functions.
user defined functions
Now let's see the second one the second type of library function is user defined functions
user-defined functions let's see the definition for user-defined function .
Definition for user-defined function
the functions which are defined by the user so here the name itself specifies the meaning the functions which are defined by the user are known as user defined functions
thanks for reading.
0 Comments