Ask Question
23 February, 23:18

Write the definition of a function printArray, which has two parameters. The first parameter is an array of integers and the second is an int, the number of elements in the array. The function does not return a value. The function prints out each element of the array, on a line by itself, in the order the elements appear in the array, and does not print anything else.

+5
Answers (1)
  1. 24 February, 02:45
    0
    public static void printArray (int [] intArray, int elements) {

    for (int i = 0; i
    System. out. println ("The element " + (i+1) + " is "+intArray[i]);

    }

    }

    A complete java program with a call to the method printArray () is given in the explanation section

    Explanation:

    public class ArrayPrinting {

    public static void printArray (int [] intArray, int elements) {

    for (int i = 0; i
    System. out. println ("The element " + (i+1) + " is "+intArray[i]);

    }

    }

    public static void main (String[] args) {

    //Declare and initialize an Array

    int [] newArray = {10,11,12,13,14,15,16,17,18,19,20};

    //Call the method printArray ()

    printArray (newArray, 10);

    }

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write the definition of a function printArray, which has two parameters. The first parameter is an array of integers and the second is an ...” 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