Count Even and Odd
Count Even and Odd
EasyArrays38% accepted
Given N integers, count how many are even and how many are odd. Print the even count on the first line, the odd count on the second. This builds on the modulo operator and applies it inside an array traversal.
Approach
Given N integers, print the count of even numbers on one line and odd numbers on the next.
Input
5
1 2 3 4 5
Output
2 3
More Arrays problems
Browse all coding problems →solution.py
Loading editor...
Test 1
Test 2
Test 3
Press Run to test your custom input, or Submit to judge against all test cases.
Sign in to continue
Create a free account to run code, submit solutions and track progress.
- Free forever — no credit card
- 10+ languages with live execution
- Points, streaks & leaderboards