Split Program in C language:- Q)Write a program to create array and split the array into two parts i.e. even and odd. Note:-You can als...
Split Program in C language:-
Q)Write a program to create array and split the array into two parts i.e. even and odd.
Note:-You can also create this program in c++(c plus plus),java,c#(c sharp) languages with the same logic.
Q)Write a program to create array and split the array into two parts i.e. even and odd.
Note:-You can also create this program in c++(c plus plus),java,c#(c sharp) languages with the same logic.
void main()
{
int a[20],e[20],o[20],i,j,k,n;
clrscr();
printf("Enter array limit");
scanf("%d",&n);
printf("Enter array element");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
j=k=0;
for(i=0;i<n;i++)
{
if(a[i]%2==0)
{
e[j]=a[i];
j++;
}
else
{
o[k]=a[i];
k++;
}
}
printf("Even Array");
for(i=0;i<j;i++)
printf("%d",e[i]);
printf("Odd Array");
for(i=0;i<k;i++)
printf("%d",o[i]);
getch();
}
If you have any query then leave your comments and don't forgot to follow me on Google+,Facebook,Twitter.
COMMENTS