Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following code segment, where num is a properly declared and initialized integer variable. The following code segment is intended to set foundRow and

Consider the following code segment, where num is a properly declared and initialized integer variable. The following code segment is intended to set foundRow and foundCol to the row and column indexes of an array element containing num. The code segment does not work as intended.
int[][] arr ={{10,11,12,13},
{22,24,26,28},
{15,16,17,18},
{40,41,42,43}};
int foundRow =-1;
int foundCol =-1;
for (int j =0; j < arr.length; j++)
{
for (int k =1; k < arr[0].length; k++)
{
if (arr[j][k]== num)
{
foundRow = j;
foundCol = k;
}
}
}
Which of the following values for num can be used as a test case to show that the code segment does not work as intended?

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

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

1285427106, 978-1285427102

More Books

Students also viewed these Databases questions

Question

What is the role of communication (Chapter 4) in leadership?

Answered: 1 week ago