# A C program to separate even and odd of array put them in two arrays – IGNOU MCA Assignment 2017 – 18

By | November 13, 2017

MASTER OF COMPUTER APPLICATIONS
Course Code: MCS-011
Course Title : Problem Solving and Programming
Assignment Number : MCA(1)/011/Assign/2017-18
Maximum Marks : 100

Write a C program to separate even and odd numbers of an array and put them in two arrays.- IGNOU MCA Assignment 2017 – 18

Program:

#include<stdio.h>
void main()
{
int I,J=0,K=0,NUM[]={1,2,3,4,5,6,7,8,9,10},EVEN[10],ODD[10];
clrscr();
printf(“\nNUMBERS IN AN ARRAY ARE : \n”);
for(I=0;I!=10;I++)
printf(“%d\t”,NUM[I]);
for(I=0;I!=10;I++)
{
if(NUM[I]%2==0)
{
EVEN[J++]=NUM[I];
}
else if(NUM[I]%2!=0)
{
ODD[K++]=NUM[I];
}
}
EVEN[J]=ODD[K]=NULL;
printf(“\nTOTAL EVEN NUMBER ARE : \n”);
for(I=0;EVEN[I]!=NULL;I++)
printf(“%d\t”,EVEN[I]);
printf(“\n”);
printf(“\nTOTAL ODD NUMBER ARE : \n”);
for(I=0;ODD[I]!=NULL;I++)
printf(“%d\t”,ODD[I]);
getch();
}

Code:

 Source code
```#include<stdio.h>
void main()
{
int I,J=0,K=0,NUM[]={1,2,3,4,5,6,7,8,9,10},EVEN[10],ODD[10];
clrscr();
printf("\nNUMBERS IN AN ARRAY ARE : \n");
for(I=0;I!=10;I++)
printf("%d\t",NUM[I]);
for(I=0;I!=10;I++)
{
if(NUM[I]%2==0)
{
EVEN[J++]=NUM[I];
}
else if(NUM[I]%2!=0)
{
ODD[K++]=NUM[I];
}
}
EVEN[J]=ODD[K]=NULL;
printf("\nTOTAL EVEN NUMBER ARE : \n");
for(I=0;EVEN[I]!=NULL;I++)
printf("%d\t",EVEN[I]);
printf("\n");
printf("\nTOTAL ODD NUMBER ARE : \n");
for(I=0;ODD[I]!=NULL;I++)
printf("%d\t",ODD[I]);
getch();
}```

Screen Shots: