Count even numbers
Java
Easy
4 views
Problem Description
Task: return how many values are even in the given int array. Keep it simple with one loop.
Output Format
Return value
Constraints
Return 0 for empty array.
Official Solution
static int countEvens(int[] a){int c=0;for(int x:a) if((x&1)==0) c++;return c;}
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!