Find the error(s) in the following code. The twoDArrays method should create a two- dimensional array and initialize all its values to 1.
```
1 private void twoDArrays()
2 {
3 int[][] array = new int[ 4 ][ 4 ];
4
5 // assign 1 to all cell values
6 for ( int i = 0; i < 4; i++ )
7 {
8 array[ i ][ i ] = 1;
9
10 } // end for
11
12 } // end method twoDArrays
```
The for statement used will only change the cells located in array[ 0 ][ 0 ], array[ 1 ][ 1 ], array[ 2 ][ 2 ] and array[ 3 ][ 3 ]. There must be a second for statement added to change the values in the entire two-dimensional array.
```
1 private void twoDArrays()
2 {
3 int[][] array = new int[ 4 ][ 4 ];
4
5 // assign 1 to all cell values
6 for ( int i = 0; i < 4; i++ )
7 {
8 for ( int j = 0; j < 4; j++ )
9 {
10 array[ i ][ j ] = 1;
11
12 } // end inner for
13
14 } // end for
15
16 } // end method twoDArrays
```
You might also like to view...
In the following statement, what is 22.0? cout << sqrt(22.0);
A) A memory location. B) A parameter. C) An argument. D) A default value. E) An l value.
Filling the screen with a photograph by applying the photo to the entire slide ________ should be considered when appropriate
Fill in the blank(s) with correct word
Other file types that can be opened in Excel 2016, such as text files, data tables, and files created using previous Excel versions are known as ________ files
Fill in the blank(s) with the appropriate word(s).
Identify the letter of the choice that best matches the example.
A. Regroup selected objects. B. Select sequential slides. C. Open the Replace dialog box. D. Open the Spelling dialog box. E. Right-align text. F. Display the Research task pane. G. Select non-sequential slides. H. Spelling dialog box; word is spelled correctly but not found in dictionaries. I. Ungroup selected objects. J. Spelling dialog box; change all occurrences of misspelled word with replacement word.