Code:
#include<stdio.h>
#include<math.h>
#define nRow 10
#define nCol 10

int main()
{
  int mat[nRow][nCol];
  int i=0,j=0,k=34,nCount=0;
  for(i=0;i<nRow;++i)
  {
    for(j=0;j<nCol;++j)
    {
       mat[i][j] = rand()%128;
       printf("%d ",mat[i][j]);
    }
    printf("\n");
  }


  for(i=0;i<nRow;++i)
  {
    for(j=0;j<nCol;++j)
    {
      if( (i+1) < nRow && (j+1) <nCol )
      {
        if( mat[i][j]>k && ((mat[i+1][j]>=k && mat[i][j+1]>=k) || (mat[i+1][j]<k && mat[i][j+1]<k)))
         ++nCount;
      }
    }
  }
printf("%d\n",nCount);

  return 0;
}
Try it..For any further doubts post you queries!!!