#include #define N 1000 main(void) { long i; long a=0; long x=0, y=N; for (i=0; i<2*N-1; i++) { if ((x+1)*(x+1) + y*y < N*N) { x++; a = a + y; } else { y--; } } printf("pi is nearly %.10f\n", ((double) a)/(N*N)*4); }