Monday, August 24, 2009

C++ libraries

C++ includes several different libraries. They provide a variety of different functions. So the programmer does not need to reinvent the wheel. The functions in a library are made available with the include directive:

#include <library_name>

For example,

iostream for I/O operations or
iomanip for manipulating the output

Let's take a closer look at a new one called cmath.
cmath contains predefined math related functions. The functions (listed in the table) can be used in a program by adding #include <cmath> at the beginning of the source code.

functiondescription
abs( x )Absolute value of real value x
pow( x,y )x raised to power y
sqrt( x )Square root of x
ceil( x )Least integer greater than or equal to x
floor( x )Greatest integer less than or equal to x
exp( x )Exponential function e^x
log( x )Natural logarithm of x
log10( x )Base 10 logarithm of x
sin( x )Sine of x (in radians)
cos( x )Cosine of x (in radians)
tan( x )Tangent of x (in radians)
asin( x )inverse sine of x
acos( x )Inverse cosine of x
atan( x )Inverse tangent of x
sinh( x )Hyperbolic sine of x
cosh( x )Hyperbolic cosine of x
tanh( x )Hyperbolic tangent of x



Reference: C++ reference, cpp reference, wikipedia


Previous post

Next post




No comments:

Post a Comment