Array Question 20
Question 20. Write a Program to count the odd and even elements of array.
Program
class Solution { public void countOddEven(int[] arr, int n) { int even=0; int odd=0; for(int i=0;i<n;i++){ if(arr[i]%2==0){ even++; } else { odd++; } } System.out.println(odd+" "+ even); } } |