Part 2: C++ -Program a 3x3 matrix in C++, but have the user input/store the valu
ID: 3718124 • Letter: P
Question
Part 2: C++ -Program a 3x3 matrix in C++, but have the user input/store the values (use integers (whole numbers) in each of the 9 cells of the matrix when using the program -After the user inputs al 9 values into the cells of the matrix, the program then asks you which cell (row & column) you would like to look up. You'll need to input row then followed by a column to select an individual cell. The output should be the value stored in the cell. The program then asks for another cell to look upExplanation / Answer
#include <iostream>
using namespace std;
int main()
{
int matrix[3][3],i,j,row,column;
char response;
for(i=0;i<3;i++){
for(j=0;j<3;j++){
cin >> (matrix[i][j]);
}
}
cout << "Enter row to lookup";
cin >> row;
cout << "Enter column to lookup";
cin >> column;
cout<<matrix[row][column];
cout<<"Do you wish to continue for another cell (y/n)";
cin>>response;
switch(response)
{
case 'y':
cout << "Enter row to lookup";
cin >> row;
cout << "Enter column to lookup";
cin >> column,' ';
cout<<matrix[row][column];
break;
case 'n':
cout << "Ok then! No row to lookup";
break;
default: cout<<"invalid choice";
}
return 1;
}