in reply to
Re: New student, can we write this program in perl...
in thread New student, can we write this program in perl...
Thank you Choroba Sir for your interest , please have a look at C code.
#include<stdio.h>
#include<conio.h>
void main()
{
int a[20],b[20],c[20],i,j=0,k=0,n;
clrscr();
printf("Enter the number of elements");
scanf("%d",&n);
printf("Enter n numbers\n");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
if((a[i]%2)==0)
{
b[j]=a[i];
j++;
}
else
{
c[k]=a[i];
k++;
}
}
printf("The even numbers are\n");
for(i=0;i<j;i++)
{
printf("%d\n",b[i]);
}
printf("The odd numbers are\n");
for(i=0;i<k;i++)
{
printf("%d\n",c[i]);
}
getch();
}
It will basically input an array of 'n' numbers and then separate it into two arrays, one contains odd numbers and one contains even numbers.
Hoping to hear from you soon.