Advertisement
Guest User

Untitled

a guest
Jan 16th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. int factorial( int n);
  2. #define PI 3.14
  3. void main()
  4. {
  5. int num,i,j,sign=1;
  6. float sum=0.0,term=0.0,x;
  7. printf("Enter the value of X: ");
  8. scanf("%f",&x);
  9. printf("Enter number of terms: ");
  10. scanf("%d",&num);
  11. printf("sin(%.2f)=",x);
  12. x=x*PI/180;
  13. j=1;
  14. for(i=1;i<=num;i++)
  15. {
  16. term= sign*(pow(x,j)/factorial(j));
  17. sign*=-1;
  18. sum+=term;
  19. j+=2;
  20. }
  21. printf("%f",sum);
  22. }
  23. int factorial(int n)
  24. {
  25. if(n==0)
  26. return 1;
  27. else
  28. return n*factorial(n-1);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement