Functions Inherited from C
As C++ evolved from C, many of the functions have been passed down to the new language. We'll discuss them in this lesson.
C++ inherited many numeric functions from C. They need the header < cmath >. The table below shows the names of these functions:
pow |
sin |
tanh |
asinh |
fabs |
exp |
cos |
asin |
aconsh |
fmod |
sqrt |
tan |
acos |
atanh |
frexp |
log |
sinh |
atan |
ceil |
ldexp |
log10 |
cosh |
atan2 |
floor |
modf |
Mathematical functions in the cmath library
Additionally, C++ inherits further mathematical functions from C. They are defined in the header < cstdlib >. Once more, the names of mathematical functions in < cstdlib >:
abs |
llabs |
ldiv |
srand |
labs |
div |
lldiv |
rand |
Mathematical functions in < cstdlib >
All functions for integers are available for the types int
, long
and long long
; all functions for floating-point numbers are available for the types float
, double
, and long double
.
The numeric functions need to be qualified with the namespace std
.