Hello everyone.
I was given this assignement to do. I am not asking anyone to do this for me at all. I am just looking for some direction on how to solve it. That is all. Any hints are greatly appreciative.
The assignment.
Write a program which includes a definition of the function SHIFT(), described as follows: SHIFT() shifts the stored values of five character variables in a circular fashion. The program initializes the variables c1,c2,c3,c4 and c5 to the values 'A', 'B', 'C', 'D', and 'E' respectively. Then the function call
SHIFT(c1,c2,c3,c4,c5) ;
causes the varaibles c1, c2, ...c5 to have the values 'B', 'C', 'D', 'E' and 'A', respectively.
Your program should call SHIFT() five times, printing out, in turn, BCDEA, CDEAB, DEABC, EABCD and ABCDE. Include SHIFT() in a program containing the following main():
Code:int main() { char c1 = 'A', c2 = 'B', c3 = 'C', c4 = 'D', c5 = 'E'; for (int i = 1; i <= 5; i++){ SHIFT(c1, c2, c3, c4, c5); cout << c1 << c2 << c3 << c4 << c5 << ' '; } return 0; }
Ok, I am vairly confident with my C++ skills and understand how functions work and all and even how to code them.
Without using a computer the way I would do this on paper is that I have is that I will record the the initial order of the letters A,B,C,D, E and each time through the loop I will just shift them by taking A and moving at the end of the list to be after E. Then, the next round would be B,C,D,E,A and then I would repeat by taking B and putting it at the end which would be after A.
I guess the reason I am posting this message here is that I am asking what C++ datatypes or functions can I use to help create these shift behavior? Would using reference ( the & ) assist me?
Again, I am not asking for anyone to do this for me, and I don't want anyone too. I just need some direction on how to approach this problem and that is all.
Thanks for your time and any hints given.