Advertisement
ebx

drugi_kolokvijum_a_pi

ebx
May 3rd, 2012
420
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.32 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #define TACNOST 0.001
  4.  
  5. int main(int argc, char** argv) {
  6.     double pi=0;
  7.     int n=1;
  8.     int jedan=1;
  9.     while (1) {
  10.         pi += jedan*(double)1/n;
  11.         if ((double)1/n < TACNOST) break;
  12.         n+=2;
  13.         jedan = -jedan;
  14.     }
  15.     printf("pi = %.33lf", pi*4);
  16.     return 0;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement