Question: manual trace the following code int numbers [5][3] = { {1, 2, 5} , {2, 4, 3}, {1, 9, 8} , {2, 6, 5}, {7,

manual trace the following code

int numbers [5][3] = { {1, 2, 5} , {2, 4, 3}, {1, 9, 8} , {2, 6, 5}, {7, 4, 2}};

int counts [9] = {0};

int digit = 1; //keeps track of numbers from 1 through 9

while (digit <= 9)

{

for (int row = 0; row < 5; row = row + 1)

for (int col = 0; col < 3; col = col + 1)

//count the number of times the digit appears in the numbers array

if (numbers[row] [col} == digit)

counts[digit - 1] = counts[digit - 1] + 1;

//end if

//end for

//end for

digit = digit + 1; //look for next digit

}//end while

//display counts

for (int x = 0; x < 9; x = x + 1)

cout << "The number " << x + 1 << " appears "

<< counts [x] << " time(s) ." << endl;

// end for

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!