#include <stdio.h>
#include <conio.h>
int main()
{
int i, a[10], loc1=0, loc2=0, max1=0, max2=0;
for(i=1; i<=5; i++)
{
printf("Enter number: ");
scanf("%d", &a[i]);
}
for(i=1; i<=5; i++)
{
if(max1<a[i])
{
max2=max1;
max1=a[i];
loc2=loc1;
loc1=i;
}
if(max2<a[i] && a[i]<max1)
{
max2=a[i];
loc2=i;
}
}
printf("First largest is %d at %d and Second largest is %d at %d",max1, loc1, max2, loc2);
getch();
}
#include <conio.h>
int main()
{
int i, a[10], loc1=0, loc2=0, max1=0, max2=0;
for(i=1; i<=5; i++)
{
printf("Enter number: ");
scanf("%d", &a[i]);
}
for(i=1; i<=5; i++)
{
if(max1<a[i])
{
max2=max1;
max1=a[i];
loc2=loc1;
loc1=i;
}
if(max2<a[i] && a[i]<max1)
{
max2=a[i];
loc2=i;
}
}
printf("First largest is %d at %d and Second largest is %d at %d",max1, loc1, max2, loc2);
getch();
}