I am trying to find the largest even and odd numbers from the given numbers
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int arr[20],eve[20],odd[20],b,a,c,d,lar=0,larg=0;
cout<<"enter the number of numbers";
cin>>a;
cout<<"enter the numbers";
for(int i=0;i<a;i++)
{
cin>>arr[i];
}
for(int j=0;j<i;j++)
{
b=arr[j]%2;
if(b==0)
{
eve[c]=arr[j];
cout<<"even numbers"<<eve[c]<<endl;
}
if(b==1)
{
odd[d]=arr[j];
cout<<"odd numbers"<<odd[d]<<endl;
}
}
for(int k=0;k<c;k++)
{
if(eve[k]>lar)
lar=eve[k];
}
cout<<"largest of even numbers is"<<lar<<endl;
for(int l=0;l<d;l++)
{
if(odd[l]>larg)
larg=odd[l];
}
cout<<"largest of odd numbers is"<<larg;
getch();
}
I get even and odd numbers differentiated
for example
I put
1
8
7
4
5
6
then I get
odd number 1
even number8
odd number 7
even number 4
odd number 5
even number 6