Display the number of even numbers on even positions in the sequence.
Input
5
1 2 4 5 6
Output
2
Printable View
Display the number of even numbers on even positions in the sequence.
Input
5
1 2 4 5 6
Output
2
You're not expecting us to do your assignment for you, are you? Because we won't.
What are you having problems with?
Just iterate through the indices 0, 2, 4, 6... and check if the number at this position is even or not (using modulo).
You need 2 variables - counter and position. If position is odd, ignore current number, otherwise check if the current number is even and increment counter.
true,
i guess i was only thinking of how short to get it, not how complex it would be.
i didnt think of having one variable and cin ing it multiple times either.