Question
Page 43, Problem #2- Rewrite the code so that it works properly. You can not use go to . Your program should query the user
Page 43, Problem #2- Rewrite the code so that it works properly. You can not use go to. Your program should query the user for the value to be searched for. You can either hard wire data into the n x n matrix or permit the user to fill the matrix interactively. Remember that a matrix is a static structure; it is not acceptable to set the size of the matrix at run-time; it must be fixed at compile-time. The use of break to exit a loop or a function should be avoided (and will be penalized).
Code from text follows:
/* Search the entries of the n x n matrix mat in rowise order for an entry equal to item*/
bool found;
for (int row=0; row for (int col=0; col if (mat[row][col]==item) found=true; else found=false; if (found) cout<<"item found "; else cout<<"item not found "
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started