math function in c

math function in c

C language allows programmers to perform mathematical operations by the functions defined in math.h header file. in the math.h header file contains number of functions to perform mathematical operation

pow()

Declaration : double pow(double x, double y);
This function returns the value of x with power y

sqrt()

Declaration : double sqrt(double x);
This function return the square root of x, where x>=0

floor()

Declaration : double floor(double x);
This function find the largest integer number not greater than x and return it as double
for example :
x=5.3 return value 5.0
x=-5.3 return value -6.0

ceil()

Declaration : double ceil(double x)
This function return the value which is grater than or equal to this number example
x=2.4 returns 3.0
x=-2.4 returns -2

log()

Declaration double log(double arg);
This log() is return the natural logarithm(with base e) of argument,where arg>0

log10()

log10()
Declaration double log10(double arg);
This log10() returns base 10 logarithm of the argument, where arg>0

exp()

exp()
Declaration: double exp(double y);
This exp(double y) returns the y

sin()

sin()
Declaration: double sin(double y);
This sin(double arg) returns the trigonometric sine of the any argument, where the argument should be in radius

cos()

cos()
Declaration: double cos(double y);
This cos(double arg) returns the cosine of the argument y

tan()

tan()
Declaration: double tan(double y);
This tan(double y) returns the trigonomatric tanget of y, where argument is in the radians

#include<stdio.h>
#include<math.h>
int main()
{
printf("\n%f",pow(2,4));
printf("\n%f",pow(3,3));
printf("\n%f",ceil(3.6));
printf("\n%f",ceil(3.3));
printf("\n%f",sqrt(16));
printf("\n%f",sqrt(7));
printf("\n%f",floor(3.6));
printf("\n%f",floor(3.2));
printf("\n%d",abs(-12));
return 0;
}

16.000000
27.000000
4.000000
4.000000
4.000000
2.645751
3.000000
3.000000
12