Write a program  to find the second biggest number using an array of n number using c 


#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,arr[20],large,second_large;
clrscr();
printf("\n Enter the number of elements in the array");
scanf("%d", &n);
for(i=0;i<n;i++)
{
printf("\n Enter the number:");
scanf("%d",&arr[i]);
}
for(i=0;i<n;i++)
{
if(arr[i]>large)
large=arr[i];
}
for(i=0;i<n;i++)
{
if(arr[i]!=large)
{
if(arr[i]>second_large)
second_large=arr[i];
}
}
printf("\n The numbers you entered are:");
for(i=0;i<n;i++)
printf("%d",arr[i]);
printf("\n The largest of these number is:%d",large);
printf("\n The second largest of these number is:%d",second_largest);
getch();
}




Output


enter the number of element in the array:5
Enter the number:1
Enter the number:2
Enter the number:3
Enter the number:4
Enter the number:5
The numbers you entered are in the array:
1 2 3 4 5
The largest of these number is:5
The second largest of these numbers is:4

















Comments