# Math.h Functions in C Library

## Library Function Math.h

On this page we will discuss about important math.h functions in C library.These functions are predefined in math.h library like sqrt( ), pow( ),sin( ).etc.We will discuss what are the functionality of these functions and how to use this in program.These library function are important to understand the basics of C programming. ## Important math.h Functions in C

Sr.No.FunctionsDescription
1.double ceil(double y)
Returns the smallest integer value greater than or equal to y.
2.double floor(double y)Returns the largest integer value less than or equal to y.
3.double fabs(double y)Returns the absolute value of y.
4.double log(double y)Returns the natural logarithm  of y.
5.double sqrt(double y)Returns the square root of y.
6.double pow(double x, double y)Returns x raised to the power of y.
7.double exp(double y)Returns the value of e raised to the yth power.
8.double cos(double y)Returns the cosine of a radian angle y.
9.double acos(double y)Returns the arc cosine of y in radians.
10.double tanh(double y)Returns the hyperbolic tangent of y.
11.double log10(double y)Returns the common logarithm (base-10 logarithm) of y.
12.double fmod(double x, double y)Returns the remainder of x divided by y.
13.double asin(double y)Returns the arc sine of y in radians.
14.double sin(double y)Returns the sine of a radian angle y.

## Program 1:(sqrt, pow, and exp)

Run

```#include <stdio.h>
#include <math.h>

int main ()
{
double y = 16.0;
printf ("square root of %.1f is %.4f. \n", y, sqrt (y));
printf ("exp of %.1f is %.4f. \n", y, exp (y));
printf ("squared value of %.1f is %.4f. \n", y, pow (y, 2));
return 0;
}

```

### Output:

```square root of 16.0 is 4.0000.
exp of 16.0 is 8886110.5205.
squared value of 16.0 is 256.0000.
```

## Program 2:(cos, acos and tanh)

Run
```#include <stdio.h>
#include <math.h>

int main ()
{
double y = 16.0;
printf ("hyperbolic tangent of %.1f is %.4f. \n", y, tanh (y));
printf ("cosine of π is %.4f. \n", cos (M_PI));
printf ("arc cosine of cos(π) is %.4f. \n", acos (cos (M_PI)));

return 0;
}
```

### Output:

```hyperbolic tangent of 16.0 is 1.0000.
cosine of π is -1.0000.
arc cosine of cos(π) is 3.1416.
```

## Program 3:(ceil, floor, and fabs)

Run
```#include <stdio.h>
#include <math.h>

int main ()
{
double y = -9.5;
printf ("ceil value of %.1f is %.1f. \n", y, ceil (y));
printf ("floor value of %.1f is %.1f. \n", y, floor (y));
printf ("absolute value of %.1f is %.1f. \n", y, fabs (y));
return 0;
}
```

### Output:

```ceil value of -9.5 is -9.0.
floor value of -9.5 is -10.0.
absolute value of -9.5 is 9.5.
```

### Related Banners

Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription

## Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others