The question is part of a programming lab and my code is wrong but I do not know why. Can someone teach me why the code for the following question is wrong?
Write the definition of a function named rotate4ints that is passed four int variables. The function returns nothing but rotates the values of the four variables: the first variable, gets the value of the last of the four, the second gets the value of the first, the third the value of the second, and the last (fourth) variable gets the value of the third. So, if i , j , k , and m have (respectively) the values 15, 47, 6 and 23, and the invocation rotate4ints(i,j,k,m) is made, then upon return, the values of i , j , k , and m will be 23, 15, 47 and 6 respectively.
Also when the following line is reached i=m
then i will be the same as m.
Then j will be the same as i. then m will be the same as k. So essentially your code makes all the variables equal each other. I doubt that's what you want
hey gdookie. sorry for my dumb reply, since I still don't know much about functions, here's my tip.
just by looking onto how you initialize your variables. you could conclude that all the variables will have the same values. since for example;
just in time you call out your function rotate4ints(a,b,c,d) the result would be.
a = d which is 4, so a = 4
b = a which is 4, so b = 4
c = b which is 4, so c = 4
d = a which is 4, so d = 4
having an output of all the same value of your initialized 'k'.
a = 4
b = 4
c = 4
d = 4
I guess I am not capable of showing the correct code but at least I tried answering your post. Hope I helped =)