Question: C++ program Exercise #4: Array Shifting Write a function named shift_right that takes as its arguments the following a one dimensional array of floating point
Exercise #4: Array Shifting Write a function named "shift_right" that takes as its arguments the following a one dimensional array of floating point values; an integer, cal it N that tells the number of cells in the array an integer, l "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, cal 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 left to right. Thus, for example, if the array passed to the function looks like this: 5.81 2.619.113.417.015.118.810.31-4.118.012.7 I etc ifleft has the value 3, right has the value 7, and distance has the value 2, then the function should shift the contents of cells 3,4,5,6, and 7 to the right by 2 cells, so that when the function returns, the array will have been changed so that it looks like this 5.8 | 2.6 I 9.1 I 0.00 I 0.00 I 3.4 I 7.0 I 5.1 I 8.8 I 0.3 2.7 l etc. The values 0.00 in cells 3 and 4 indicate that we don't care what numbers are in those cells when the function returns (you can put any default values instead). Note that the content of cells 8 and 9
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
