#include <stdio.h>
void main() {
int arr1[50], n, i, j = 0, lrg, lrg2nd;
printf("Input the size of the array : ");
scanf("%d", &n);
printf("\nInput %d elements in the array :\n", n);
for (i = 0; i < n; i++) {
scanf("%d", &arr1[i]);
}
lrg = 0;
for (i = 0; i < n; i++) {
if (lrg < arr1[i]) {
lrg = arr1[i];
j = i;
}
}
lrg2nd = 0;
for (i = 0; i < n; i++) {
if (i == j) {
i++;
i--;
} else {
if (lrg2nd < arr1[i]) {
lrg2nd = arr1[i];
}
}
}
printf("\nThe Second largest element in the array is : %d ", lrg2nd);
}
To embed this project on your website, copy the following code and paste it into your website's HTML: