Forget your code. Take a pencil and paper, and draw your array of 4 x 4 (or 2 x 2), whatever size you need. Make it simple as you need it to be.
Now, look at the paper from above, paper flat on the table or desk. Now slowly turn the paper 90° to the right. Repeat that until you have noted the 1st position of every element of the array, and it's last value, after the array is rotated.
<< THAT'S how you learn to solve a problem. >>
If you use a different value for every element of the array, it may help you.
Write down the equation that solves the change in position for any element, after the array has been rotated, given it's starting position. It's simple arithmetic, so no trig or calc is necessary, here.
Doing it this way, you WILL LEARN and remember, how this works, for a very long time. If I just told you, you'd forget it inside of a week.
And have fun, because this is a fun exercise. ;)