Sir/Ma’am,
If elemnet is not element is not present in array, then what will be termination statement??
Thank u
my code is as:
#include
using namespace std;
int main()
{
int arr[10][10];
int n;
cin>>n;
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
cin>>arr[i][j];
}
}
int ans;
cout<<"Enter the number to be searched: ";
cin>>ans;
int i=0;
int j=n-1;
int num=arr[0][n-1];
while(num!=ans)
{
if(num<ans)
{
i=i+1;
num=arr[i][j];
}
else if(num>ans)
{
j=j-1;
num=arr[i][j];
}
}
cout<<“The number is found is at “<< i+1<<” row and “<<j+1<<” column”;
}