Math.h library in C Programming

Today I will try to explore math.h (library) header file provided to the programmers by turbo C++ compiler. Mostly people try to implement their own implementation of these functions; this is due to the lack of knowledge about Math library provided by turbo C++. So here we go.

Find the Square root of a number

Function: double sqrt(double);
It calculates the positive square root of the input value which is given as double data type.

Find the Power of a number

Function: double pow(double x, double y)
It calculates the value of xy . If both the values are 0 then the value returned by the function is 0. If the result is a more bigger number; which a variable of type double can not contain; then the function return an error (HUGE_VAL).

Find Ceil and Floor values

double ceil(double x);
double florr(double x);

ceil() finds the smallest integer value of the value passed as the parameter, but the returned values is not greater than the values passed to the function. Where as floor() finds the largest integer value not bigger than the value passed as the parameter.


Leave a Reply