Will this code satisfy the requirements?
#include<stdio.h>
main(void)
{
int a[5],i,highest1,highest2,flag=0;
for(i=0;i<5;i++)
scanf("%d",&a[i]);
highest1=a[0];
highest2=a[1];
for(i=1;i<5;i++)
{
if( a[i] > highest1)
{
highest2 = highest1;
highest1 = a[i];
flag++;
}
else if( a[i] > highest2 )
{
highest2 = a[i];
flag++;
}
else
flag++;
}
if( !flag )
highest2 = highest1;
printf("%d",highest2);
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---