#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main(void)
{
int i;
double interval;
for(i=0;i<30;i++)
{
interval = i/10.0;
printf("sin(%lf) = %lf \t", interval, abs(sin(interval)));
};
printf("\n+++++++++\n");
return 0;
}
the sin value of each interval term is coming out to be 0.000000. example sin(0.60000) = 0.000000
The abs
function is an integer function. Which means you have undefined behavior since you use the mismatching format specifier %lf
.
For floating point you need to use fabs
.