C Library Functions
The Standard Function Library in C is a huge library of sub-libraries, each
of which contains the code for several functions. In order to make use of
these libraries, link each library in the broader library through the use
of header files. The actual definitions of these functions are stored in
separate library files, and declarations in header files. In order to use
these functions, we have to include the header file in the program. Below
are some header files with descriptions:
S Header
No. Files Description
It checks the value of an expression that we expect to
be true under normal circumstances.
1 <assert.h>
If the expression is a nonzero value, the assert macro
does nothing.
2 <complex.h> A set of functions for manipulating complex numbers.
Defines macro constants specifying the
3 <float.h> implementation-specific properties of the
floating-point library.
These limits specify that a variable cannot store any
value beyond these limits, for example-
4 <limits.h>
An unsigned character can store up to a maximum
value of 255.
The math.h header defines various mathematical
functions and one macro. All the Functions
5 <math.h>
in this library take double as an argument and return
double as the result.
The stdio.h header defines three variable types,
6 <stdio.h> several macros, and various
function for performing input and output.
7 <time.h> Defines date and time handling functions.
S Header
No. Files Description
Strings are defined as an array of characters. The
difference between a character array
8 <string.h>
and a string is that a string is terminated with a special
character ‘\0’.
stdio.h: This library is use to use the printf() function, the
header file <stdio.h> should be included in the program. Below
is the C program to implement the above approach:
C
1
// C program to implement
2
// the above approach
3
#include <stdio.h>
4
5
// Driver code
6
int main()
7
{
8
printf("C PROGRAM");
9
return 0;
10
}
Output
C PROGRAM
math.h– To perform any operation related to mathematics, it is
necessary to include math.h header file.
Example 1: sqrt()
Syntax-
double sqrt(double x)
Below is the C program to calculate the square root of any
number:
C
1
// C program to implement
2
// the above approach
3
#include <math.h>
4
#include <stdio.h>
5
6
// Driver code
7
int main()
8
{
9
double number, squareRoot;
10
11
number = 12.5;
12
13
// Computing the square root
14
squareRoot = sqrt(number);
15
16
printf("Square root of %.2lf = %.2lf",
17
number, squareRoot);
18
return 0;
19
}
Output
Square root of 12.50 = 3.54