As I posted earlier,I ve been practicing C for my upcoming Graduate Studies Venture.Just reading online books and practicing some basic codes.I happen to play with taylors Sinx Series on Netbeans IDE and when I run the program with values of 'n' and angle in radians,the compiler is stuck.The only thing I can see is that my processor usage is full and I cant do anything else.
Here is the code that I made using Sinx formula from calculus book.
I just need some hints or implication as to where I can improve so that code will work without any problems with IDE.Further any suggestions for a good book of C and C++.Preferably American author.
Here is the code that I made using Sinx formula from calculus book.
Code:
#include <stdio.h>
#include <math.h>
int main()
{
int n,m;
double sesum;
double sinx(double,double);
printf("Enter the limit of series greater than 0\n");
scanf("%f",&n);
printf("Enter the angle in radians\n");
scanf("%f",&m);
sesum=sinx(n,m);
printf("The value of series is %f",sesum);
return 0;
}
double sinx(double p,double q)
{
int i;
double fact(double);
double sum=0;
for(i=0;i<=p;i++)
{
sum=sum+(pow(q,2*i+1)/fact(2*i+1))*(pow(-1,i));
}
return sum;
}
double fact(double a)
{
double fact=1;
int j;
for(j=a;j>=1;j--)
{
fact=a * (a-1);
}
return fact;
}
I just need some hints or implication as to where I can improve so that code will work without any problems with IDE.Further any suggestions for a good book of C and C++.Preferably American author.
Comment