Ask Question
3 May, 03:36

Write a function called displayArray7. The function should accept a twodimensional array as an argument and display its contents on the screen. The function should work with any of the following arrays: a. int hours[5][7]; b. int stamps[8][7]; c. int autos[12][7]; d. int cats[50][7];

+3
Answers (1)
  1. 3 May, 06:13
    0
    In Java programming language:

    public static void displayArray7 (int[][] arr) {

    {

    / / Loop through all rows

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

    / / Loop through all elements of current row

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

    System. out. print (arr[i][j] + " ");

    }

    }

    Explanation:

    Working with option a in the question int hours[5][7]; We created a main method, initialized the array hours[5][7]; and called displayArray7

    public class ANot {

    public static void main (String[] args) {

    int hours[][] = {{1, 2, 3, 4, 5, 6, 6},

    {3, 4, 5, 6, 6, 7, 7},

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

    {56, 78, 54, 1, 21, 34, 4},

    {5, 4, 6, 7, 7, 6, 7}};

    / / Calling the displayArra7 method

    displayArray7 (hours);

    }

    }
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write a function called displayArray7. The function should accept a twodimensional array as an argument and display its contents on the ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers