I am trying to find the the ceil of a variable which was been assigned a value but when I pass the function ceil("variable name") it throws an error.
#include <stdio.h>
#include <math.h>
int main()
{
double num = 8.33;
int result;
result = ceil(num);
printf("Ceiling integer of %.2f = %d", num, result);
return 0;
}
And the error which I am gettin is--
/usr/bin/ld: /tmp/ccG3j9iB.o: in function `main':
maximumRebounding.c:(.text+0x1f): undefined reference to `ceil'
collect2: error: ld returned 1 exit status
With the developer tools you are using, you must include -lm
on the command that builds the executable file to tell the linker to use the math library. Put it on the command after object modules and libraries that use routines from the math library.