All these functions are defined in <math.h> header file. The math.h header defines various mathematical functions including trigonometric and hyperbolic functions so, we must include this file in the beginning of the program as #include<math.h>
The commonly used functions of math.h header file are given below:
|
|
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. |
fabs(number) |
Returns the
absolute value of a number. |
|
6. |
round() |
Returns the
nearest integer value of the given number |
|
7. |
log()
|
Computes the
natural logarithm of an argument. |
|
8. |
log10()
|
Returns the
logarithm to the base of 10. |
|
9. |
exp()
|
Returns the result
of e raised
to the power of x. |
|
10. |
frexp()
|
Splits a
floating-point value into a fraction and an exponent. |
|
11. |
fmod()
|
Returns the
remainder |
|
12. |
sin()
|
Returns the sine
of a number. |
|
13. |
sinh()
|
Returns the
hyperbolic sine of a number |
|
14. |
cos()
|
Returns the cosine
of a number |
|
15. |
cosh()
|
Returns the
hyperbolic cosine of a number |
|
16. |
tan()
|
Returns tangent of
the argument passed. |
|
17. |
tanh()
|
Computes the
hyperbolic tangent of an argument. |
|
18. |
asin()
|
Returns the arc sine
of a number |
|
19. |
acos()
|
Returns the arc cosine
of a number |
|
20. |
atan(d)
|
Returns the arc
tangent of a number |
Example:
A simple example of math functions found in "math.h" header file:
#include<stdio.h>
#include <math.h>
int main()
{
printf("\n%.2f",ceil(3.3));
printf("\n%.2f",floor(3.2));
printf("\n%.2f",sqrt(16));
printf("\n%.2f",sqrt(7));
printf("\n%.2f",pow(2,4));
printf("\n%.2f",pow(3,3));
printf("\n%d",abs(-12));
return 0;
}


0 Comments
if you have any doubts plz let me know...