Question: Exercise #4: Array Shiftin Write a function named shift_right that takes as its arguments the following: a one dimensional array of floating point values; an
Exercise #4: Array Shiftin Write a function named "shift_right" that takes as its arguments the following: a one dimensional array of floating point values; an integer, call it N that tells the number of cells in the array. an integer, call it "left", that tells the leftmost cell of the part of the array to be shifted; an integer, call it "right", that tells the rightmost cell of the part of the array to be shifted; a positive integer, call it "distance" that tells how many cells to shift by The function should make sure that left is less than or equal to right, and that distance is greater than zero. If either of these conditions fails, the function should return the value 1 to indicate an error. Otherwise it should shift by distance cells the content of the array cells with subscripts running from lefft to right. Thus, for example, if the array passed to the function looks like this: 2 5.8 2.61 9.113.417.0 5.118.8I 0.3I -4.18.02.71 etc
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
