#include<stdio.h>
#include<conio.h>
main()
{
int un[10], i, big1, big2;
printf("Enter array elements: ");
for ( i = 0; i < 10; ++i )
scanf("%d", &un[i]);
big1 = un[0];
for ( i = 1; i < 10; ++i )
{
if ( big1 < un[i] )
big1 = un[i];
if ( big1 != un[0] )
big2 = un[0];
else
big2 = un[1];
}
for ( i = 1; i < 10; ++i )
{
if ( big1 != un[i] && big2
< un[i] )
big2 = un[i];
}
printf("Second largest: %d\n",
big2);
return 0;
}
No comments:
Post a Comment