Ask Question

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];

+2
Answers (1)
  1. 1 February, 04:24
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers