Storing Integers at odd and even indexes in array

Hello every one here is my problem given below
Input values (say 10) from user in array, if the value is even then place at even
index else at odd index.
Then how could i solve this problem?
Lookup the modulus operator, i.e. %
1)Set up an array with 20 elements and initialize all elements to 0
2)Declare two pointers, ptr_even to point to array element [0] and ptr_odd to point at array element [1]
3)Get the user value using cin>><enter>
4)Process the value with %==0. If this returns true the value is even otherwise odd. (as ajh32 above suggests)
5)Place the value in the array (if even) where ptr_even points otherwise where ptr_odd points.
6)Increment the previously active pointer 2 element 'forward' to the next even element or to the next odd element. (one pointer does not move)
7)Repeat 3) - 6) until all numbers from user have been entered into the array.
8)Print the array (say using a for loop) to prove your code.
Topic archived. No new replies allowed.