Send Close Add comments: (status displays here)
Got it!  This site uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.nbsp; Note: This appears on each machine/browser from which this site is accessed.
C math functions


1. C math functions
Many important math functions in C are in the math.h library.

Below is an example usage of some of the functions.

Note: If the degrees were 0.0, then the slope would be undefined and a divide by zero error would be raised. This is ignored for now.

2. Square root
The mathematical formula

square root function
can be written as the following coding expression using the math library sqrt function.
sqrt(x)


3. Power
The mathematical formula

power function
can be written as the following coding expression using the math library pow function.
pow(x, n)

The following program shows how to use the math library sqrt and pow functions.

Here is the C code.


4. Examples of input and output
Here are some examples of input and output for the above program code.

Here is an example input.

For the above example input, here is the expected output.

Here is an example input.

For the above example input, here is the expected output.

Here is an example input.

For the above example input, here is the expected output.

Here is the output of the C code.

5. Trigonometric functions
The math library provides many mathematical functions.

Here is the C code.


6. Examples of input and output
Here are some examples of input and output for the above program code.

Here is an example input.

For the above example input, here is the expected output.

Here is an example input.

For the above example input, here is the expected output.


7. End of page

8. Multiple choice questions for this page