/* Print the value of pi */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define DECIMAL_ACCURACY 1E-6
/**
* Using Vietis equation
*/
int main() {
double fac = sqrt(2.0);
double val = 1.0;
do {
val *= fac / 2.0;
fac = sqrt(2 + fac);
} while(2.0 - fac > DECIMAL_ACCURACY);
printf("Value of pi is: %g\n", 2.0 / val);
return 0;
}