Course Solutions Uncategorized (Solved) : Code Needs Modified Include Include Include Int Main Int N X Unsigned Int Seed Double R Pr Q38012850 . . . .

(Solved) : Code Needs Modified Include Include Include Int Main Int N X Unsigned Int Seed Double R Pr Q38012850 . . . .

 

Code that needs to be modified:

#include

#include

#include

int main()

{

int i,N,x;

unsigned int seed;

double R;

printf(“nEnter number of iterations and seed”);

printf(“n”);

scanf(“%i %u”, &N,&seed);

srand(seed);

  

for(i=0;i

{

R=(double)rand()/RAND_MAX;

if (R<0.5)

x=x+1;

else

x=x-1;

}

printf(“Final location is “);

printf(“%d”,x);

printf(“n”);

}

Question: Write a code that generates N pairs of random numbers.Call the first member of each pair x and the second member y. Counthow many of the N pairs obey x^2+y^2<1. Call that number M, andhave your code print out M/N. What do you get for M/N when N=10^2?How about N=10^4, N=10^6 and N=10^8? Explain your result. Thelanguage used is C.

Hint: It might be useful to multiply the value you get for M/Nby four.

Warning: Be careful how you define

OR

PayPal Gateway not configured

OR

PayPal Gateway not configured

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post