/*programming for partition the elements of the array so that all the even numbers move to one side and odd numbers to the other side of the array.*/
#include<stdio. h>
int main()
{
int i,t,p,x,z,temp;
printf("enter the size of array\n");
scanf("%d",&i);
int a[i];
printf("enter the element of array\n");
for(t=0;t<i;t++ )
scanf("%d",&a[t]);
for(x=0;x<i;x++ )
{
for(p=0;p<i;p++ )
{
if (a[p]%2==1)
{
temp=a[p];
a[p]=a[p+1];
a[p+1]=temp;
}
}
}
printf("require d array:");
for(z=0;z<i;z++ )
printf("%d\n",a[z]);
return 0;
}
#include<stdio. h>
int main()
{
int i,t,p,x,z,temp;
printf("enter the size of array\n");
scanf("%d",&i);
int a[i];
printf("enter the element of array\n");
for(t=0;t<i;t++ )
scanf("%d",&a[t]);
for(x=0;x<i;x++ )
{
for(p=0;p<i;p++ )
{
if (a[p]%2==1)
{
temp=a[p];
a[p]=a[p+1];
a[p+1]=temp;
}
}
}
printf("require d array:");
for(z=0;z<i;z++ )
printf("%d\n",a[z]);
return 0;
}
Comment