main() { int c=0,x,i,y; for(i=0;i<N;i++) { x=random();y=random(); if((x2+y2)<1) c++; } print(c); }
random() is a function which returns random number between $0$ or $1$, $N$ is a large number what is the output of the program?
random()
This is monte carlo method to estimate value of pi.
Value of c : N*π/4
For reference to monte carlo method: http://www.dartmouth.edu/~rc/classes/soft_dev/C_simple_ex.html
64.3k questions
77.9k answers
244k comments
80.0k users