// MonteCarloPI.cpp : Defines the entry point for the console application. // This is an iterative method to calculate PI. The more iterations, the more accurate #include "stdafx.h" #include #include #include #include #define SEED 35791246 int _tmain(int argc, _TCHAR* argv[]) { int niter=0; double x, y; int i, count=0; //number of points 1st quadrant of unit circle double z; double pi; printf("Enter, number of iterations: "); scanf_s("%d",&niter); /* initialize random numbers */ srand(SEED); count=0; for ( i=0; i