Subscribe For Free Updates!

We'll not spam mate! We promise.

Sunday, 26 August 2012

C++ code to Store & displaying even and odd numbers in two arrays from one array list



// Store & displaying even and odd numbers in two arrays from one array list
// Programmer name: Sohail Ahmed
// Dated: 16/05/2011

#include<iostream.h>
#include<stdio.h>
#include<conio.h>

int List[10]={3,7,6,1,2,5,4,9,8,10};

void main()
{
clrscr();
int even[4];
int odd[4];
int i=0;
int j=0;
for(int count=0; count<=9; count++)
{
if(List[count]%2==0)
{
even[i]=List[count];
i++;
}
else
{
odd[j]=List[count];
j++;
}
}
cout<<"\nEven numbers: ";
for(i=0; i<=4; i++)
{
cout<<even[i]<<" ";
}
cout<<"\nOdd numbers: ";
for(j=0; j<=4; j++)
{
cout<<odd[j]<<" ";
}
getch();
}

Socializer Widget By CodingLovers
SOCIALIZE IT →
FOLLOW US →
SHARE IT →

0 comments:

Post a Comment