169k views
5 votes
Given array[6][6] = 1,2,3,4,6,5

1,2,3,4,6,5
1,2,3,4,6,5
1,2,3,4,6,5
1,2,3,4,6,5
1,2,3,4,6,5;
What indexes would you put in to print out the second 6?

User Plspl
by
8.3k points

1 Answer

3 votes

Final answer:

To find the indexes of the second 6 in the given array, iterate through each element and keep track of the indexes. The indexes would be (1,4) as the second 6 is at the second row and the fifth column.

Step-by-step explanation:

To find the indexes of the second 6 in the given array, we need to iterate through each element and keep track of the indexes. Here is the step-by-step process:

  1. Start with the first element of the array and initialize a variable count to 0.
  2. Iterate through each element of the array.
  3. If the element is equal to 6, increment the count by 1.
  4. If the count is equal to 2, store the indexes in separate variables (row and column).
  5. Print the row and column variables, which will give you the indexes of the second 6.

In this case, the indexes would be (1,4) as the second 6 is at the second row and the fifth column.

User Ferus
by
8.0k points