a[x] = a[i]; -- By doing this you are just adding a value to the different index of the same array.It will not work. To separate value of array you need to create two different arrays. Look at the below code.
#include<stdio.h>
void main()
{
int a[5]={0,2,3,4,5};
int i,j=0,k=0;
int x[5];
int y[5];
for (i=0,j=0,k=0; i<=4; i++)
{
if( a[i] % 2 == 0 )
{
x[j] = a[i];
j++;
}
else
{
y[k] = a[i];
k++;
}
}
for (i=0;i<=j;i++)
{
printf("%d ", x[i]);
}
printf("\n");
for (i=0;i<=k;i++)
{
printf("%d ", y[i]);
}
}
The output of the above code is
0 2 4 0
3 5 4195472
please ignore the garbage values.