Counting Even and Odd Numbers
Video Summary: https://youtu.be/c5H29u-DMgM
In this exercise, you will count the number of even and odd integers in the given array:
Suggested steps:
- Create a for loop that will run for the size of the array. You can find this with sizeof(numbers)/sizeof(int) instead of counting them out yourself. You need to divide because sizeof will return the size in bytes, so to get the actual number you need to divide by the number of bytes in an integer
- Write an if statement that increments the counter of numEven if the number is even, and an else that increments numOdd if it is not
When you are finished, your output might look like this:
There are 5 even numbers and 5 odd numbers