Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define TACNOST 0.001
- int main (int argc, char** argv) {
- int n=1;
- double pi=2.0;
- int potrebnaTacnost = 0;
- while (potrebnaTacnost == 0) {
- n+=2;
- pi *= (double)(n-1)/n;
- pi *= (double)(n+1)/n;
- if ((1- (double)(n-1)/n) < TACNOST ) potrebnaTacnost=1;
- }
- pi *= 2;
- printf("pi = %.3lf", pi);
- getchar();
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement