Question: How to solve this on C++? Write a function named shift rightthat takes as its arguments the following a one dimensional array of floating point
How to solve this on C++?


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; e . an integer, call it"right", that tells the rightmost cell of the part ofthe array to be shifted; . a positive integer, call it"distance" that tells howmany 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 shiftby distance cells the content of the array cells with subscripts running from left to right. Thus, for example. ifthe array passed to the function looks like this 3 5.8 L 2.6 | 9.1 3.417.0 L 5.1 L 8.8 0.3 4.1L 8.0 | 2.7etc. 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 1 3 10 5.8 L 2.6 | 9.1 0.00 L0.00 |3.4 7.0 5.1 L8.8 0.3 2.7 | etc. Thevalues 0.00 in cells 3 and 4 indicate that we don't care what numbers are in those cells whein the function returns (you can put any default values instead). Note that the content of cells 8 and 9 3/4
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
