This program finds the value of π (pi) with the Monte Carlo method.

#1Consiter that unit circle (radious = 1 ) within a square with sides equal to 2.If we pick a random point(x,y) were both x and y are

between -1,........1. the probability that this random point lies

inside the circle is given as the proportion:

P( x^2 + y^2<1 ) = Area circle/Area square = ( pi )/4

#2If we pick a random point N times and M of those times the point lies inside the unit circle ,the probabillity of that a random point lies inside the unit circle is given as:

P ( x^2 + y^2<1 ) = M/N

#3 But if N becomes very large (theoretically infinite)the true probabilities #1-#2 tend to became equal

4M/N=pi

Can you help me in my problem. I'm new with the programming

I want to make drand48() function tou give me values in the interval [-1,1]

and i dont know how....

Code:#include<stdio.h> #include<stdlib.h> #define TOTAL_NUM 100000 int m=0,n=0;double x,y,pi; int main() { for(n=0;n<TOTAL_NUM;n++) { x=............i need some code here; y=............also i need some code here; if((x*x)+(y*y)<1) m++; } pi=4.0*m/n; printf("%lf",pi) return 0; }