Display the number of even numbers on even positions in the sequence.

Input

5

1 2 4 5 6

Output

2

Printable View

- 02-25-2011teodorrupiFind the number of even numbers on even positions
Display the number of even numbers on even positions in the sequence.

Input

5

1 2 4 5 6

Output

2 - 02-25-2011rags_to_riches
You're not expecting us to do your assignment for you, are you? Because we won't.

- 02-25-2011kmdv
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. - 02-26-2011bobknows
- 02-27-2011kmdv
- 02-27-2011bobknows
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.