#include <stdio.h>
main(){
int mat[4][4] = {
{10,20,30,40},
{15,25,35,45},
{27,29,37,48},
{32,33,39,50}
};
int n = 4 , x=29;
int smallest = mat[0][0] , largset = mat[n-1][n-1];
if(x<smallest || x>largset){
return -1;
}
int i = 0, j = n-1;
while(i<n &&j>=0){
if (mat[i][j] == x){
printf("\n the element found at %d %d",i,j);
return 0;
}
if(mat[i][j] > x){
j--;
}else{
i++;
}
}
printf("\n element not found");
return 0;
}