pastebin

Paste Search Dynamic
Recent pastes
Division number
  1. #include <stdio.h>
  2. #include <math.h>
  3. #define PARTS 1
  4.  
  5. int main(void) {
  6. double old_y,new_y,old_x,new_x,d,S;
  7. int i;
  8.  
  9. d = 1.0 / PARTS;
  10. S = 0;
  11. old_y = 1;
  12. old_x = 0;
  13.  
  14. for (i = 1;i <= PARTS;i++) {
  15. new_x = i * d;
  16. new_y = sqrt(1 - new_x * new_x);
  17.  
  18. S += ((old_y + new_y) * d / 2);
  19.  
  20. old_y = new_y;
  21. old_x = new_x;
  22. }
  23.  
  24. printf (Divisionnumber= %d,π = %fn",PARTS,S * 4);
  25.  
  26. return 0;
  27. }
Parsed in 0.005 seconds