Array Shift function [Help Needed !]

Write a function

 
void cycle( double * array, int length)


The function should move the values of the array up one postion, moving the last value to the start

For example values 1,2,3,4,5 should be replaced by 5,1,2,3,4.

The length of the array is given by the length parameter.

Im a Beginner to C++ and my lecture wasn't very great a explaining basic of C++ instead give us 2000 word document instead of actually teaching it.
Can anyone help with this question and explain each step ?
closed account (SECMoG1T)
1. Create a temporal variable to hold the last indexed value in the array.
2. Move the rest of the values from the last-1 index up one position up to first index of your array.
3. Assign the value you stored in the temporal variable to the 1st index.
4 .repeate the routine as many time as you wish
Last edited on
Hey Thank you for Instructions.

I've a Question Actually,

The question i posted at the top what is this actually called ?, like what method or technique ?
If you're looking for a good term for a search, "array rotation" should do the trick.
ahh Thanks for the term.

any recommended good video tutorials on this question ?
Topic archived. No new replies allowed.