C Program to compute the sin series
#include<stdio .h="">
#include<conio .h="">
#include<math .h="">
int fact(int no)
{
int j,f=1;
for(j=1;j<=no;j++)
{
f=f*j;
}
return f;
}
void main()
{
int x,n,count=0,i,j,f;
float sin=0,p;
clrscr();
printf("\nEnter value for x: ");
scanf("%d",&x);
printf("\nEnter value for n: ");
scanf("%d",&n);
i=1;
while(i<=n)
{
count++;
p=pow(x,i);
f=fact(i);
if(count%2!=0)
sin=sin+p/f;
else
sin=sin-p/f;
i=i+2;
}
printf("\nValue of sin(%d): %0.3f",x,sin);
getch();
}
***************OUTPUT*****************
Enter value for x: 1
Enter value for n: 7
Value of sin(1): 0.841</math></conio></stdio>