• 0

C Programming help


Question

Hi, I was given a normal lab question and I have difficulty in understand and doing it. The question is:

zsvins.jpg

2eydi83.jpg

2chrs49.jpg

And lastly I was given the sample codes to start off.

rwhohk.jpg

All I know is that I need to put this codes.

#define RAND(X) ((double) rand()/RAND_MAX * X)

Any help?

Thanks!

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

You need to get a bunch of random coordinates and measure the euclidean distance [ sqrt ( (Xpoint - Xcenter)^2 + (Ypoint - Ycenter)^2) ) ] from that point to the center of the square, if it is greater than r then it's outside the circle, keep a count of the total attempts ( N ) and the ones that have been inside ( C ) and there you go.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.