Ask Question
3 January, 08:13

Write the declaration statement for a two-dimensional array X of integers with five rows and five columns that accepts 25 integers from the user.

+3
Answers (1)
  1. 3 January, 10:43
    0
    int[ ][ ] X = new int[5][5];

    It can also be declared and initialized this way:

    int[][] X = {

    {1,2,3,6,8},

    {4, 5, 6, 9},

    {7,5,6,8,9},

    {8,5,8,8,9},

    {10,2,6,8,11},

    };

    Explanation:

    Above is a declaration of a two-dimensional array that can hold 5*5=25 int values. A java program is given below:

    public class JavaTwoD{

    public static void main (String args[ ]) {

    / / creating the 5X5 array

    int[ ][ ] X = new int[5][5];

    / / looping through the array to add elements

    for (int i = 0; i < X. length; i++) {

    for (int j = 0; j < X[i]. length; j++) {

    X[i][j] = i * j;

    }

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write the declaration statement for a two-dimensional array X of integers with five rows and five columns that accepts 25 integers from the ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers