C Program : Find Sin x Series 1-x2/2! + x4/4! - x6/6! + x8/8! - .........


Write a Program to find Sin s series 1-x2/2! + x4/4! - x6/6! + x8/8! - .....


 #include 
 main()
  {
    int i = 1, n, y;
    float sum, t, x;
    printf("Enter the number of terms and degree : ");
    scanf("%d %f", &n, &y);
    x = y * 3.142 / 180;
    sum = 1;
    t = 1;
    while( i < n)
     {
       t = ((-t) * x * x) / ((2 * i) * (2 * i - 1));
       sum = sum + t;
       i++;
     }
    printf(" The value of Cos(%d) is %f ", y, sum);
  }

Input : Enter the number of terms and degree : 10 60
Output : The value of Cos(60) is 0.49999

0 Komentar untuk "C Program : Find Sin x Series 1-x2/2! + x4/4! - x6/6! + x8/8! - ........."

Back To Top