C Program to find the sum of the sine series


C Program to find the sum of the sine series , Sine Series In C, Sum of Sine Series In C Language, C Assignment to find Sin Series in C .

#include
#include
#include
void main()
{
int i = 2, n, s = 1, x, pwr = 1, dr;
float nr = 1, x1, sum;
clrscr();
printf("\n\n\t ENTER THE ANGLE...: ");
scanf("%d", &x);
x1 = 3.142 * (x / 180.0);
sum = x1;
printf("\n\t ENTER THE NUMBER OF TERMS...: ");
scanf("%d", &n);
while(i <= n)
{
pwr = pwr + 2;
dr = dr * pwr * (pwr - 1);
sum = sum + (nr / dr) * s;
s = s * (-1);
nr = nr * x1 * x1;
i+= 2;
}
printf("\n\t THE SUM OF THE SINE SERIES IS..: %0.3f",sum);
getch();
}



1 comment:

  1. //SINE SERIES (is it correct??)

    #include
    #include
    #include
    void main()
    {
    clrscr();
    int i,k,n;
    float x,s,term;
    s=0;
    term=1;
    i=1;
    puts("Enter the angle");
    scanf("%f", &x);
    x=x*3.14/180;
    puts("Enter the number of terms upto which summation will occur");
    scanf("%d", &n);
    for(k=1;k<n;k++)
    {
    s=s+term;
    term=term*x*x*(-1)/((i+1)*(i+2));
    i=i+2;
    }
    s=x*s;
    printf("the sum of %f is %f", x, s);
    getch();
    }

    ReplyDelete