C Unit-4 PPT
C Unit-4 PPT
Language
Unit -4
Standard Library Functions
• Library functions are the inbuilt function in C that are grouped and placed at
a common place called the library.
• The library functions are created by the designers of compilers.
• All C standard library functions are defined inside the different header files
saved with the extension .h.
• We need to include these header files in our program to make use of the
library functions defined in such header files.
SN Header Description
file
1 stdio.h This is a standard input/output header file. It contains all the
library functions regarding standard input/output like printf(),
scanf(), gets(), puts(), getc(), putc(), fopen(), fclose(), fprintf(),
fscanf(), fgets(), fputs(), fgetc(), fputc(), fseek(), ftell(), rewind()
etc
2 conio.h This is a console input/output header file like clrscr(), getch()
etc
3 string.h It contains all string related library functions like gets(), puts(),
strlen(), strcpy(),strcat(), strcmp(), strrev(), strlwr(), strupr() etc.
4 stdlib.h This header file contains all the general library functions like
malloc(), calloc(), realloc(), free(), exit() etc.
5 math.h This header file contains all the math operations related
functions like sqrt(), pow() etc.
6 ctype.h This header file contains all character handling functions like
isalnum(), isalpha etc
7 process.h This header file contains function declarations and macros used
conio.h header file functions
Sr.No. Functions
Description
SN Function Description
1) ceil(number) rounds up the given number. It returns the integer
value which is greater than or equal to given
number.
2) floor(number) rounds down the given number. It returns the
integer value which is less than or equal to given
number.
3) sqrt(number) returns the square root of given number.
4) pow(base, exponent) returns the power of given number.
5) abs(number) returns the absolute value of given number.
6) sin(number)/ returns the sin/cos/tan value of given number in
cos(number)/ radian .
tan(number)
Example:
#include<stdio.h>
#include <math.h>
void main()
{
printf("\n%f",ceil(3.6));
printf("\n%f",ceil(3.3));
printf("\n%f",floor(3.6)); Output:
printf("\n%f",floor(3.2)); 4.000000
printf("\n%f",sqrt(16)); 4.000000
printf("\n%f",sqrt(7)); 3.000000
printf("\n%f",pow(2,4)); 3.000000
printf("\n%f",pow(3,3)); 4.000000
printf("\n%d",abs(-12)); 2.645751
16.000000
} 27.000000
12
ctype.h header file functions
Output:
Enter a character: H
H is an alphanumeric character.
Enter a character: %
% is not an alphanumeric character.
process.h header file functions
S.No. Function Description
creates a new thread of execution within the current
1 _beginthread
process.
#include <stdio.h>
void main(int argc, char *argv[] )
{
printf("Program name is: %s\n", argv[0]);
if(argc < 2)
{
printf("No argument passed through command line.\n");
}
else
{
printf("First argument is: %s\n", argv[1]);
}
}
Output:.When we write in command line like ./program hello then
output is
Program name is: program
First argument is: hello