Ask 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 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.

+2
Answers (1)
  1. 10 September, 03:55
    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 & 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