Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- double factorial(double n){
- if(n==0)
- return 1;
- return (n * factorial(n-1.0));
- }
- int main(){
- int i=1,flag=1;
- double sinx,term, x= (M_PI/2);
- while(i<=1000){
- term =(double) (powl(x,(double)i)/factorial((double)i));
- if(flag==1){
- sinx += term;
- flag=0;
- }else{
- sinx -= term;
- flag=1;
- }
- i += 2;
- }
- printf("sinx=>%f \nsin=>%f\n",sinx,sin(x));
- return 1;
- }
Add Comment
Please, Sign In to add comment