#include<stdio.h>//header file
#include<conio.h>//header file
void main() //starting of the main() function
{
int i,n,t,j,a[10]; //declaration of the variables
clrscr();
printf("program that finds 2nd max in a given list of integers");
printf("\n\n\n\t\t------------INPUT-------------");
printf("\n\nenter the no. of elements to be entered in the list");//taking input
from the user
scanf("%d",&n);
printf("\nenter the elements in the list");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<=1;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]<a[j])
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
printf("\n\n\n\t\t------------OUTPUT------------");
printf("\n\nthe second max. value in the list is=%d",a[1]);//printing output
getch();
}