CyberSlug Rules!

Beginner Programming CMPS060

Prof. Paulo Franca

Home

Syllabus

Login

Objects

Download

Staff only

Math.h

  • header file containing the most usual math functions:
  • must use: #include <math.h>
There are trigonometric functions:
function for any float value x ...
sin(x)
cos(x)
tan(x)
asin(x)
acos(x)
atan(x)
returns the sine of arc x.
returns the cosine of arc x.
returns the tangent of arc x.
returns the arc sine x.
returns the arc cosine x.
returns the arc tangent x.

There are also exponential functions

exp(x) returns the exponential ex.
log(x) returns the natural (base e) logarithm of x.
log10(x) returns the decimal logarithm of x.

Also the functions:

sqrt(x) returns the square root of x.
fabs(x) returns the absolute value of x.
ceil(x) returns the round up value of x.
floor(x) returns the round down value of x.
rand() returns a random (well, almost) integer

example: square root