Programming of 3 x 7 trick
Your random_rearrange_num function has a bias.  If you want an equal chance of getting every permutation, implement something like the Fisher-Yates shuffle.  Your implementation is actually a common implementation error.  You can read about it here.

I would implement it as follows: (my C is mighty rusty and I don't have a compiler on hand to verify syntax or correctness)

void random_rearrange_num(int p[][numCols])
{
  int r, k, l, temp;
  for (int i = numRows * numCols - 1; i &gt; 1; i--)
  {
    r = rand() % i; //select from only the remaining numbers
    k = r / numRows;
    l = r % numRows;
    temp = p[i][j]; 
    p[i][j] = p[k][l];
    p[k][l] = temp;
  }
}