Saturday, October 22, 2011

solution of sine series

#include <stdio.h>
#include <conio.h>
#include <math.h>

int main()
{
    float t, x, nu, sum = 0;
    int y, n, a, b, c, de=1;
    printf("Enter the value of x and n: \n");
    scanf("%f %d", &x, &n);
   
    for(a=1; a<=n; ++a) {
             y = 2*a-1;
             nu = pow(x, y);
             for(de=1, b=1; b<=2*a-1; ++b) de*=b;
             t = nu*pow(-1, a+1)/de;
             sum+=t;
             }
            
             printf("%f", sum);
            
             getch();
             return 0;
            
}

No comments:

Post a Comment