Guest User

Untitled

a guest
Jul 19th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include<math.h>
  4.  
  5. float tinhsopi(long n){
  6. float s = (float) 2/3;
  7.  
  8. for(long i=2;i<=n;i++)
  9. if (i%2==0) s= s + (float) 1/ (float) (2*i+1);
  10. else s = s - (float) 1/ (float) (2*i+1);
  11.  
  12. return(s);
  13. }
  14.  
  15. void main(){
  16.  
  17. long n;
  18. printf("\n nhap n=");
  19. scanf("%ld",&n);
  20.  
  21. float sopi = (float) tinhsopi(n) *4;
  22.  
  23. printf("\n so pi la %3.3f", sopi);
  24.  
  25. getch();
  26. }
Add Comment
Please, Sign In to add comment