Search Contact information
University of Cambridge Home Department of Engineering
University of Cambridge >  Engineering Department >  computing help
next up previous
Next: Assignment statements Up: C++ Summary Previous: Expressions

Predefined functions

You need to have the #include <math> directive at the top of your program to use these. All parameters and return values are of type double.

Function Description
sqrt(x) square root
sin(x) trigonometric sine of x (in radians)
cos(x) trigonometric cosine of x (in radians)
tan(x) trigonometric tangent of x (in radians)
exp(x) exponential function
log(x) natural logarithm of x (base e)
log10(x) logarithm of x to base 10
fabs(x) absolute value (unsigned)
rint(x) round x to nearest integer
pow(x,y) x raised to power y
© Cambridge University Engineering Dept
Information provided by Tim Love
2006-12-08