#include<stdio.h>
main()
{
int i,n,arr[100],a=0,b=0;
printf("enter the no of elements in the array\n");
scanf("%d",&n);
printf("enter the elements of the array\n");
for(i=0;i<n;i++)
scanf("%d",&arr[i]);
for(i=1;i<n;i++)
if(arr[a]<arr[i])
{
b=arr[a];
a=i;
}
else
if(b<arr[i])
b=arr[i];
printf("\n the second largest number is %d ",b);
}
main()
{
int i,n,arr[100],a=0,b=0;
printf("enter the no of elements in the array\n");
scanf("%d",&n);
printf("enter the elements of the array\n");
for(i=0;i<n;i++)
scanf("%d",&arr[i]);
if(arr[a]<arr[i])
{
b=arr[a];
a=i;
}
else
if(b<arr[i])
b=arr[i];
printf("\n the second largest number is %d ",b);
}
No comments:
Post a Comment