Write a method named printOdd() that accepts an integer array as argument and print all the odd numbers in the array. You may assume all the numbers in the array are greater than 0. (Hint: Odd number is any integer that CANNOT be divided exactly by 2). This method should have the following header.

Respuesta :

Debel

Answer & Explanation:

//written in java

public class Main {

   private static void printOdd(int[] list) {

       for (int value : list) {

           if (value % 2 == 1) {

               System.out.println(value);

           }

       }

   }

   public static void main(String[] args) {

       printOdd(new int[]{5, 6, 2, 3, 11, 4, 7});

   }

}

ACCESS MORE