I have a 2-dimensional array(3×7) with numbers between 0 to 20. I would like to randomly change the locations, hence it is randomly rearranged. But it seems that every time it is run it has the same locations.
int arr[numRows][numCols] = {{0,1,2,3,4,5,6},{7,8,9,10,11,12,13},{14,15,16,17,18,19,20}};
random_rearrange_num(arr);
void random_rearrange_num(int p[][numCols])
{
int temp = 0,k= 0,l = 0;
for(int i = numRows -1 ; i > 0 ; i--)
{
for (int j = numCols-1;j>0; j--)
{
k = 0 + rand()/(RAND_MAX/(2-0+1)+1);
l= 0 + rand()/(RAND_MAX/(6-0+1)+1);
temp = p[i][j];
p[i][j] = p[k][l];
p[k][l] = temp;
}
}
}
I have shown the neccessary part in the question. The full code is here: https://codereview.stackexchange.com/questions/9419/programming-of-3-x-7-trick
For example: it always loads up with this first 
Second is this :

everytime i restart, the numbers are at the same location. How do i change it?
You should first initialize a seed with
srand()A common way to seed is: