Math Functions
There is also a list of math functions available, that allows you to perform mathematical tasks on numbers.
To use them, you must include the math.h header file in your program:
#include <math.h>
Square Root
To find the square root of a number, use the sqrt() function:
Example
printf("%f", sqrt(16));
Round a Number
The ceil() function rounds a number upwards to its nearest integer, and the floor() method rounds a number downwards to its nearest integer, and returns the result:
Example
printf("%f", ceil(1.4));
printf("%f",
floor(1.4));
Power
The pow() function returns the value of x to the power of y (xy):
Example
printf("%f", pow(4, 3));
Complete Math Reference
For a complete reference of math functions, go to our C <math.h> Library Reference.