Answers for "get odd number in array"

1

get odd number in array

public int[] findEvens() {
  int numberEvens = 0;
  for (int i = 0; i < numbers.length; i++) {
     if (numbers[i] % 2 == 0) {
        numberEvens++;
     }
  }
Posted by: Guest on May-29-2021
0

get odd number in array

public int[] findEvens() {
  int numberEvens = 0;
  for (int i = 0; i < numbers.length; i++) {
     if (i % 2 == 0) {
        numberEvens++;
     }
  }
Posted by: Guest on May-29-2021

Browse Popular Code Answers by Language