#include<stdio.h>
main()
{
int a[100],n,fl,sl,i;
printf("\nEnter number of terms=");
scanf("%d",&n);
printf("\nEnter the elements=");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("\nThe list =");
for(i=0;i<n;i++)
{
printf("%d ",a[i]);
}
fl=a[0];
for(i=1;i<n;i++)
{
if(fl<a[i])
fl=a[i];
}
sl=a[0];
for(i=1;i<n;i++)
{
if(sl<a[i] && a[i]<fl)
sl=a[i];
}
printf("\nThe second largest element=%d",sl);
}
main()
{
int a[100],n,fl,sl,i;
printf("\nEnter number of terms=");
scanf("%d",&n);
printf("\nEnter the elements=");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("\nThe list =");
for(i=0;i<n;i++)
{
printf("%d ",a[i]);
}
fl=a[0];
for(i=1;i<n;i++)
{
if(fl<a[i])
fl=a[i];
}
sl=a[0];
for(i=1;i<n;i++)
{
if(sl<a[i] && a[i]<fl)
sl=a[i];
}
printf("\nThe second largest element=%d",sl);
}
No comments:
Post a Comment