I show here two codes i made for this one , one code satisfies case 2 and 3 and one satisfies case 1

basically stuck on printing zero the right way if element is absent but please tell me my mistake in both the codes


Varun, pls use the following approach in your code as :

bool function(int a[100][100],int n,int m,int val)
{
int i=0,j=m-1;
while(i<n && j>=0)
{
if(a[i][j]==val)
{
return true;
}
else
if(a[i][j]<val)
{
i++;
}
else
{
j–;
}

}
return false;

}
i