Question: I need this program done in C Please do the entire code And please edit the code that i gave No other form will work
In this problem we will write a program to simulate a circular walker. A walker walks along the index of an array in a circular manner. The size of the array is n. The indices of the array elements are therefore between 0 and n -1. When the walker is at the index k, he will go to index k+ alk] for the next step, if k + alk] is between 0 and n -1. Otherwise, the modular operation is used to ensure the result is between 0 and n-1. Before the walk leaves the current index k, the value alk] is decremented by i. For example, when k 2, and n 5, if alk] 4, then kalk] 2+4-6. Applying modular operation we have 6%n = 6%5 = 1. Hence the next index is 1. Before the walker goes to index 1, al2) is decremented by 1. and heuce a[2] becomes 3. Note if alk] is 0, the walker will stop. In the starter code rotate.c, implement the function int next.index (int a], int k, int n) This function returns the index for the next step and also updates alk] before the function returns Do not change the main() function. Only write code inside the next-index() function. If vour code is correct, you will notice the walker stops at a special location. #include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
