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](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f93466a7682_91066f9346620825.jpg)
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
Get step-by-step solutions from verified subject matter experts
