As Richard mentioned, drawing this out on paper will help you see the pattern. It it is very simple.
Also - have a look at the function swap in the standard library. It will take of that aspect of things for you.
Another thing - remember to seed the random number generator (RNG) with srand(). You have two options to seed it, at minimum. One is to use a predetermined value. Prime numbers are good for that like 47 or 43 and bigger values are OK too. With a predetermined seed you will get the same sequence of random values. The other option is to use a random value for the seed. Using time is common for this. Here is an example :
int seed = time( NULL ) % RAND_MAX;
This will cause the RNG to return a more random sequence of values. It's up to you to choose what kind of sequence you want.
Lastly, you might to implement a function to display the matrix for you. You will need to do it twice so you might as well use one piece of code to do it. It might take a little while to figure out how to pass the matrix to a function so this is optional. It will likely be educational to figure it out though.
Here's a hint - you have the size defined as a constant and that's a good start. You can use typedef and define the matrix as a type and that will make it easier. ;)
Best of luck.