337,128 views
32 votes
32 votes
A 2-dimensional 3x3 array of ints, has been created and assigned to tictactoe. Write an expression whose value is that of the middle element in the middle row.

User Alex Zaraos
by
2.4k points

1 Answer

14 votes
14 votes

Answer:

tictactoe[1][1]

Step-by-step explanation:

To access arrays, square boxes might be used which means specifying the row position and column position of a certain value in an array ::

Given a 2 - dimensional 3×3 array of integers :

Creating a dummy array assigned to the variable tictactoe :

[1 2 3]

[4 5 6]

[7 8 9]

We have a 3×3 array, that is 3 rows and 3 columns.

The middle element in the middle row is located in the second row ;second colum

Row and column Indexes starts from 0

Middle element in the middle row is the value 5 and it corresponds to :

tictactoe[1][1]

We call the variable name and the we use one square box each to house the row and column position.

User Peter Cordes
by
2.7k points