Hello, I am having trouble with this program not working properly. When I set the matrix to size 1 it works properly but when its greater than 1 it does not give me the correct output. Help will be much appreciated.
int row = 0, col = 0;
bool found = false;
for (row = 0; row < n; row++) {
for (col = 0; col < n; col++)
if (mat[row][col] == item) {
found = true;
break;
}
if (found) break;
}
if (found)
cout << "item found at " << row << ", " << col << "\n";
else
cout << "item not found\n";