DPS915 Toad
Contents
Project Name Goes here
Team Members
Progress
Assignment 1
PI Calculation
Code
double xValue, yValue; for(int i = 0; i < npoints; i++) { //Generate random numbers xValue = (double) rand()/RAND_MAX; yValue = (double) rand()/RAND_MAX; if(sqrt((xValue*xValue)+(yValue*yValue)) <= 1) { circle_count++; } } double pi, ds; cout<<circle_count<<"/"<<npoints<<endl; ds = (double)circle_count/npoints; cout<<ds<<endl; pi = ((4.0)*ds); cout<<"PI = "<< pi <<endl;
"