Mathematical Function in C | C Math Functions

 

C programming language provides a set of built-in math functions that can be used to perform various mathematical operations. In many situations the mathematical functions such as sqrt(), pow(), round(), log() etc. are needed. Almost every C compiler supports these basic mathematical functions. 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 of Math Functions found in math.h header file:

 

 

Output:

Leave a Comment