Question: This is coding question please use C language that can compile and run and please comment on each section to understand the code! 1. Introduction
1. Introduction This assignment, which introduces the use of loops, solves the following problem: given a starting location in a city, how long does it take a "drunken sailor who randomly chooses his direction at each intersection to reach the city's border? You will read input values to set up the problem parameters, run several trials to determine an average number of steps for the sailor to reach the border, and output the results. This problem is an example of a "random walk," a succession of random steps that carn model real world problems like stock price fluctuation or molecules traveling through liquid. The approach is a simple approximation of a Monte Carlo experiment, in which repeated random samples are run to find a numerical result. 2. Deliverables Submit your source file by uploading it directly to your Dropbox folder. Ensure your source file name is prog4 sailor.c. You should submit only the .c file. Failure to meet this specification will reduce your grade, as described in the grading guidelines. 3. Specifications Problem description: The city is organized as a set of M x N blocks. The sailor's position, which must always be an intersection or a point on the border, can be represented as a pair of coordinates (X, Y), where 0sXSM, and 0 sY SN. The example below shows a 4 x 3 city, with the sailor at position (3, 2): Y coord North 2 West Direction East South X coord 4 At each step of a given trial, the sailor will randomly choose a direction and walk until he reaches the next intersection. A trial ends when the sailor reaches one of the city borders. Note that each new trial always uses the same starting point
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
