is there a certain algorithm to do a rotation/shift of an integer x to say n positions right?
rot(x,n)
for example...rot(1234,2)
this would be 3412...
what i tried to do was input the number, and use a while loop to mod the number by 10 and place this result into an int array. so in the end i have the number in an int array backwards so it would be...then i reverse this array so its the correct number, i then perform a a few for loop methods and it would work for say this example but when i try a different x value and also n value, the results are very unexpected.Code:array={'4','3','2','1'};
how can i go about this problem more effectively?
i looked through k&r about shifting >> but im stumped on what goes on or how shifting would work in this case.
cheers!