Explain important functions in math.h library functions using C language

CServer Side ProgrammingProgramming

All mathematical related functions are stored in math.h header file in C programming language. The functions are explained below in detail.

sin()

This function is used to find the sin value of its argument.

The syntax of sin() function is as follows −

double sin(double a);

For example,

double a=sin(3.14/2);

The output is as follows −

a=1 (approx.)

cos()

It is used to find the cos value of its argument.

The syntax for cos() function is as follows −

double cos(double a);

For example,

double a=cos(3.14/2);

The output is as follows −

a=0 (approx.)

tan()

It is used to find the tan value of its argument.

The syntax for tan() function is as follows −

double tan (double a);

For example,

double a=tan(3.14/2);

exp()

It is used to find the exponent value of its argument.

The syntax for exp() is as follows −

double exp (double a);

For example,

double a=exp(4.6);

floor()

It is used to round down a float number.

The syntax for floor() function is as follows −

Double floor(double a);

For example,

Double a=floor(93.58);

The output is as follows −

A=93

ceil()

It is used to round up a float number.

The syntax for ceil() function is as follows −

Double ceil(double a);

For example,

Double a=ceil(93.58);

The output is as follows −

A=94

abs()

It is used to find the absolute value of an integer.

The syntax for abs() function is as follows −

int abs(int a);

For example,

Int a= abs(-6);

The output is as follows −

a=6

pow()

It is used to find the power of a value.

The syntax for pow() function is as follows −

double pow(double a,double b);

For example,

double x=pow(2,3)

The output is as follows −

x=8

sqrt()

It is used to find the square root value of its argument.

The syntax for sqrt() function is as follows −

double sqrt(double a);

For example,

double x=sqrt(36);

The output is as follows −

x=6
raja
Published on 26-Mar-2021 11:56:04
Advertisements