C++ Math library Functions
The Standard C++ support many math functions that can be used for performing certain commonly used calculations.
Most frequently used math library functions are summarized in
this table
Note: The arguments variables x and y are of type double and all the functions return the data type double.
So to use the math library functions, we must include the header file math.h in conventional 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
FRIEND AND VIRTUAL FUNCTIONS
C++ introduces two new types of functions, namely, friend function and virtual function,
They are basically introduced to handled some specific tasks related to class objects. so discussions on these functions have been reserved until after the class objects are discussed. The friend functions are discussed later