C++ Programs & Stuffz

Nothing like anything!!!

Please Click on ADS!!

Please Click on the above ads given by GOOGLE , so that I can maintain my blog!!

Tuesday, August 31, 2010

Find the largest odd and even numbers from a list of numbers

//pgm to find the largest odd and even numbers from a list of numbers
#include<iostream.h>
#include<conio.h>
void main()
{
    int i,x,n,largee,largeo;
    clrscr();
    cout<<"enter the value of n"<<endl;
    cin>>n;
    cout<<"enter the numbers";
    largee=2;
    largeo=1;
    for(i=1;i<=n;i++)
    {
        cin>>x;
        if(x%2==0)
        {
            if(x>largee)
                largee=x;
        }
        else
        {
            if(x>largeo)
                largeo=x;
        }
    }
    cout<<"largee="<<largee<<endl;
    cout<<"largeo="<<largeo;
    getch();
}

0 comments:

Post a Comment

free counters