1

# 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(&#3...

## Question

###### 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(&#3...

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. Count how many of the N pairs obey x^2+y^2<1. Call that number M, and have 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. The language used is C.

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

Warning: Be careful how you define N and M. If you have variables N,M that are integers and compute N/M the computer will give you an integer which is the number of times M foes into N. Thus in N=5 an M=3 then N/M=5/3=1. Similarly if N=13 and M=2 then N/M=13/2=6. Finally, if N=1 and M=2 then N/M=1/2=0. if you want 13/2=6.5 you need to tell the computer 13 is a double (or float) by declaring it as a double(or float). This is an important point to remember in coding. If you ever write a line of C code like y=(1/2)*x; the computer will set y=0 because it will compute 1/2=0 before multiplying by x.

******* Please make sure you answer all the questions asked and please do it 100%correctly. Please write neat and very clear that way i can be able to read and understand what is being said. The language used is C.

#### Similar Solved Questions

##### EkSGjuupP229 TerShrArvkmkAMsqqCbac3hUGPBRNch1Wh2YVyNoby90F)dXGZT2GVdsz9bG5RrrinOqNBLLW%3d%3d8.classid=2293815#/learning Platform/class/s Topic 5 DQ 1 You are a hospital administrator, and you receive a...
EkSGjuupP229 TerShrArvkmkAMsqqCbac3hUGPBRNch1Wh2YVyNoby90F)dXGZT2GVdsz9bG5RrrinOqNBLLW%3d%3d8.classid=2293815#/learning Platform/class/s Topic 5 DQ 1 You are a hospital administrator, and you receive a call from a colleague at another hospital. Your colleague, who is a friend, informs you that he ha...
##### A) Iriz's stock is currently selling for RM160.00 per share and the firm's dividends are expected...
a) Iriz's stock is currently selling for RM160.00 per share and the firm's dividends are expected to grow at 5% indefinitely. In addition, Iriz's most recent dividend was RM5.50. The expected risk-free rate of return is 3%, the expected market return is 8%, and Iriz has a beta of 1.20. R...
##### What is the amount of the annual coupon payment for a bond that has 6 years...
What is the amount of the annual coupon payment for a bond that has 6 years until maturity, sells for \$1,050, and has a yield to maturity of 9.37%?...
##### In 1968, Ford decided to develop firstly a new mini car called Pinto, aiming to challenge...
In 1968, Ford decided to develop firstly a new mini car called Pinto, aiming to challenge the Beetle in American market. The price for Pinto can't be over 2000 US dollars; R&D department found the distance between the oil tank and bumper is only 10 inches. Tailgate collision experiment indic...
##### Objective: Your company (or a made-up company) is considering moving toward/away from an open office desk...
Objective: Your company (or a made-up company) is considering moving toward/away from an open office desk arrangement. Provide a business proposal to your supervisor as to why your company should (or shouldn't) make the switch using at least 3 outside sources. Please use APA formatting in additi...
##### Design a circuit that has a 3 bit binary input (representing 0 through 7) and outputs...
Design a circuit that has a 3 bit binary input (representing 0 through 7) and outputs a 1 if the input is a prime number.  A prime number (or prime) is a natural number greater than 1 that has no positive divisors other than 1 and itself. a)  Fill out a truth table that represent...
##### Correctly label the components of the upper respiratory tract. 8 02:11:00 Septal cartilage Vomer Perpendicular plate...
Correctly label the components of the upper respiratory tract. 8 02:11:00 Septal cartilage Vomer Perpendicular plate Oropharynx Nasopharynx Laryngopharynx Reset Zoom...
##### Assume that Nike and Adidas are the only sellers of athletic footwear in the United States....
Assume that Nike and Adidas are the only sellers of athletic footwear in the United States. They are deciding how much to charge for similar shoes. The choices are “High” (H) and “Outrageously High” (OH). The payoff matrix is as follows Nike's dominant strategy is to ...
##### A3. What is the Voltage gain of the following arrangement? A B
A3. What is the Voltage gain of the following arrangement? A B...
##### Name and describe briefly the 3 Theoretical Models of Human Evolution, including the researchers associated with...
Name and describe briefly the 3 Theoretical Models of Human Evolution, including the researchers associated with each one?...
##### NATO and the Warsaw Pact were two competing alliances during which time period?
NATO and the Warsaw Pact were two competing alliances during which time period?...
##### A company's fixed operating costs are \$620,000, its variable costs are \$2.55 per unit, and the...
A company's fixed operating costs are \$620,000, its variable costs are \$2.55 per unit, and the product's sales price is \$4.45. What is the company's break-even point; that is, at what unit sales volume will its income equal its costs? Round your answer to the nearest whole number....