Question: *Using C Program Ratio of Random Points in a Unit Disc Generate a pair of random numbers (x and y) between -1.0 and 1.0. Assume

*Using C Program  *Using C Program Ratio of Random Points in a Unit Disc

Ratio of Random Points in a Unit Disc Generate a pair of random numbers (x and y) between -1.0 and 1.0. Assume that (x, y) is a point in Cartesian coordinate. Calculate its distance from the origin and check whether the distance is less than 1 or not (i.e. within a unit circle). Repeat this check N times and count how many times (n) the random points are within a unit circle. Find the product of the area of the square (4) and the ratio as f(N) = 4n/N increasing N at the scale of thousands and millions. Your program will read your input N from keyboard and use a for-loop statement for the repetition. Draw a chart showing the relationship between the number of iterations (N) vs. the ratio f(N). Brainstorming: We already knew the circle ration(pi) is 3.1415926535897932384626433832795028841971... The question is how to find the pi? If a circle of radius R is inscribed inside a square with side length 2R, then the area of the circle will be pi R^2 and the area of the square will be (2R)^2. So the ratio of the area of the circle to the area of the square will be pi/4. (Monte Carlo Method) For this project, you are asked to create a separate file (distance.c) for the distance function. In the main program, you will declare the function prototype. To compile your program (myprogram.c) with the separate C code (distance.c) and the custom-built library (ecex.lib), you use the compiler by entering $ cl myprogram.c distance.c ecex.1ib

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!