math.h Functions
sqrt, pow, fabs, ceil, floor and round need #include <math.h>. Link with -lm on some systems.
Example
#include <stdio.h>
#include <math.h>
int main(void) {
printf("%.1f %.1f %.1f %.1f\n", sqrt(16), pow(2, 10), fabs(-3.5), ceil(2.1));
printf("%.0f %.0f\n", floor(2.9), round(2.5));
return 0;
}Result
4.0 1024.0 3.5 3.0 2 3
Exercise
Power.
(2, 3)Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.