#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
double s, t, x;
int n;
printf("please input x:");
scanf("%lf", &x);
t = x;
n = 1;
s = x;
do
{
n = n + 2;
t = t * (-x*x)/((float)(n) - 1)/(float)(n);
s = s + t;
}
while(fabs(t) >= 1e-8);
printf("sin(%f) = %lf\n", x , s);
system("pause");
return 0;
}
|