Find Second largest Array Element

Second Largest Array Element

#include
#include

void main()
{
int a[10],temp;
int i,j;
clrscr();
	for(i=0;i<5;i++)
	{
	printf("a[%d]=",i+1);
	scanf("%d",&a[i]);
	}
	for(i=0;i<5;i++)
		{
		for(j=i+1;j<5;j++)
			{
			if(a[i]>a[j])
				{
				temp=a[j];
				a[j]=a[i];
				a[j]=temp;
				}
			}
		}
	printf("\nThe second largest value is %d",a[3]);
getch();
}


Second Largest Element
Second Largest Element of Array
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply