Advertisement
Guest User

C++ HW unedited

a guest
Sep 22nd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. double pi = 0;
  9. long i;
  10. long n;
  11.  
  12. cin >> n;
  13. cout << "Enter the value of n: ";
  14. cout << endl;
  15.  
  16. if (i % 2 == 0)
  17. pi = pi + (1 / (2 * i + 1));
  18. else
  19. pi = pi - (1 / (2 * i + 1));
  20.  
  21. for (i = 0; i < n; i++)
  22. {
  23. pi = 0;
  24. pi = 4 * pi;
  25. }
  26.  
  27. cout << endl << "pi = " << pi << endl;
  28. return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement