There is no need to use the Third loop to check the second largest number in the array. You can only use two loops(one for insertion and another is for checking.
Refer this code.
#include <stdio.h>
int main()
{
int a[10], n;
int i;
printf("enter number of elements you want in array");
scanf("%d", &n);
printf("enter elements");
for (i = 0; i < n; i++) {
scanf("%d", &a[i]);
}
int largest1 = a[0],largest2 = a[0];
for (i = 0; i < n; i++)
{
if (a[i] > largest1)
{
largest2=largest1;
largest1 = a[i];
}
}
printf("First and second largest number is %d and %d ", largest1, largest2);
}
Hope this code will work for you.
Enjoy Coding :)