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