program to find largest two number
#include<iostream.h>
#include<conio.h>
void main()
{
int a[22],fbig=0,sbig=0,i,n;
cout<<"\n enter size :";
cin>>n;
cout<<"\n enter element :";
for(i=1;i<=n;i++)
cin>>a[i];
fbig=a[1];
for(i=2;i<=n;i++)
{
if(fbig<a[i])
{
fbig=a[i];
}
}
sbig=a[2];
for(i=3;i<=n-1;i++)
{
if(sbig<a[i])
{
sbig=a[i];
}
}
cout<<"\nfirst largest :"<<fbig;
cout<<"\n second largest :"<<sbig;
getch();
clrscr();
}
No comments:
Post a Comment