Question: Q1[40 marks] The concept of a drunkard's walk involves an individual who starts walking aimlessly from a lamp post, and with each step taken, they

 Q1[40 marks] The concept of a "drunkard's walk" involves an individual

Q1[40 marks] The concept of a "drunkard's walk" involves an individual who starts walking aimlessly from a lamp post, and with each step taken, they randomly move either north, south, east or west with a probability of 25%. As the individual takes more steps, they forget where they are and continue to take random steps. The objective is to determine the distance the individual will be from the starting point (0,0) after N number of steps. To simulate this motion of a random walker for N steps, a F The program should prompt the user to enter an integer number of steps to be taken. The program should work for any value of steps from 1 to a large number. However, if an invalid number (negative) is entered. an error message should be printed. After each step, the program sho ild print the location of the random walker with respect to the origin (lamp post). When he randon warker has completed all the steps, the program should print the square of the final squared distance from the origin (x2+y2). [hint] to use a random number between two number in c \begin{tabular}{|l} \#include \\ \#include \\ srand ( time (0)); \\ int num =( rand ()%( upper - lower +1))+ lower; \\ \hline \end{tabular} Sample output: Enter number of Moves 10 Number of Moves 10 move West at point (1,0) move North at point (1,1) move West at point (2,1) move South at point (2,) move West at point (3,) move North at point (3,1) move East at point (2,1) move West at point (3,1) move South at point (3,) move East at point (2,) The distance from origin =4 - Submit your files as Q1.c, Q2.c, and Q3.c - Submit one pdf fle contains all your output screenshot. - Include all appropriate comments in your code

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!