C examples for Data Type:float
The formula of the infinite series expansion is given here:
sin x = x - x3/3! + x5/5! - x7/7! + ...
Here, x is in radians, and it takes values in the range -1 <= x <= 1.
#include <stdio.h> int main()// w ww. j ava 2s . c o m { double sine, term, x = 0.7, z; int k = 1; char ch; term = x; sine = x; z = x * x; for (int i = 1; i <= 10; i++) { k = k + 2; term = -term * z /(k * (k - 1)); sine = sine + term; } printf("Sine of %lf is %lf\n", x, sine); return(0); }