As $T_n=\frac{x^{2n+1}}{(2n+1)!}$ and $T_1=x$
So, $T_{n-1}=\frac{x^{2n-1}}{(2n-1)!}$
So, $T_n=T_{n-1}\frac{x^2}{(2n+1)2n}$
I have utilized this so that we don't need to calculate the powers of x and the factorial every time.
I've assumed that the number of terms is not required as by repeated division, y will eventually be reduced 0 due to the limited precision of double datatype.
Also, x is to be measured in radian(not in degree), as prescribed by the Taylor Series.
void main(int argc, char **argv) { double x , sinx, y; printf("enter x:\n"); scanf("%lf",&x); sinx=y=x; int sign = -1; for (int idx = 1;; idx++) { y = y * (x / (2 * idx)) * (x/(2 * idx - 1)); if (y == 0) break; sinx = sinx + sign * y; sign = -sign; } printf("\n\nsin(%lf) = %lf", x, sinx); }