Ads Top

Sine series program using c

sine series,programming,c,computer,sin

Sine series program

#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,f=1,sin=-1;
float s,t,x;
clrscr();
printf("sine series");
printf("Enter the number of terms:");
scanf("%d",&n);
printf("Enter the value of x:");
scanf("%f",&x);
s=x;
for(i=3;i<=n;i+=2)
{
f=f*i*(i-1);
t=pow(x,i);
s=s+(sin*t)/f;
sin=sin*(-1);
}
printf("sine series:%f",s);
getch();
}


Output

Sine series
Enter the number of terms:3
Enter the value of x:6
Sine series:30.000000

No comments:

Touchfeeds. Powered by Blogger.