Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

im trying to search for a number 77 in a 3 by 3 matrix, im getting errors in the

ID: 3616693 • Letter: I

Question

 im trying to search for a number 77 in a 3 by 3 matrix, im getting errors in the for loop, can anyone figure it out, i will rate


#include <iostream>
using namespace std;
int main(void)
{
//declaring variables
int mat [3][3];
int n;
int row;
int col;
int item;
n=3;
//creating a matrix
mat [0][0]=45;
mat [0][1]=77;
mat [0][2]=93;
mat [1][0]=78;
mat [1][1]=79;
mat [1][2]=85;
mat [2][0]=72;
mat [2][1]=96;
mat [2][2]=77;
cout<<"enter the number you wish to search for: ";
cin>>item;

//searching for item in the matrix
int found;

for (int row=0; row<n; row++)
if (found!=true)
for (int col=0; col<n;col++)
if (found!=true)
if(mat[row][col]==item)
found=true;
else
found=false;
if (found)
cout<<"item found ";
else
cout<<"item not found ";

cout<<"the number its in row: "<<row+1<<endl;
cout<<"and in column: "<<col+1<<endl;

//in order to cause a system pause
cout <<" press a letter then press enter ";
cin >> n;


return 0;


}

Explanation / Answer

please rate-thanks #include using namespace std; int main(void) { //declaring variables int mat [3][3]; int n; int row; int col; int item; n=3; //creating a matrix mat [0][0]=45; mat [0][1]=77; mat [0][2]=93; mat [1][0]=78; mat [1][1]=79; mat [1][2]=85; mat [2][0]=72; mat [2][1]=96; mat [2][2]=77; coutitem; //searching for item in the matrix int found; found=false; for (int row=0; row