Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application And Administration

Authors: Michael Mannino, Michael V. Mannino

2nd Edition

0072880678, 9780072880670

Students also viewed these Databases questions

Question

=+4 What are non-union workers representations?

Answered: 1 week ago