Program to Separate Even and Odd numbers of Array

Write a program to segregate even and odd numbers in linear time complexity.

Given an array of integers of size N. We have to separate odd and even numbers of an array. First group all even numbers then odd numbers.
For Example :
Input Array : 2 7 4 1 9 5 3 8
Output Array : 2 4 8 7 1 9 5 3