Please help me find the sine series .
My program is:
#include<stdio.h>
#include<conio.h>
#include<math.h>
float facto(int a);
int main()
{
int n,g,k,y;
y=1;
float s=0.0;
float f=0.0;
float l =0.0;
float x;
int t=0;
printf(" limit is \n");
scanf("%d",&n);
printf(" no. is \n");
scanf("%d",&x);
x=3.14*(x/180.0);
while(y<(n+1))
{ g=y;
if(g%2==0)
t=-1;
else
t=1;
k=2*g;
l = facto(g+1);
f=(pow(x,(g+1))/l)*(t);
s = s+f;
y+=2;
}
printf("\n sum is %d",s);
system("pause");
return 0;
}
float facto(int c)
{ int d=1;
float fact = 1.0;
while(d<(c+1))
{
fact=fact*d;
d++;}
return(fact);
}
I am unable to get the correct thing.
For instance , if I gave limit 2 and no. as 34 or any other no. , the output is always 0.
I cant understand this , what is my mistake?
PLEASE help me find it out!:(
Thanks in advance,
hinduengg