Write a program that finds the second largest element in a given list of N numbers.
The most basic solution for this problem is that if there are two elements in the list then the smaller of the two will be the second largest. In this case, we would set the second largest number to ‘–9999’, a value not possible in the list.
In given problem, the list will be searched linearly for the required second largest number. Two variables called firstLarge and secLarge would be employed to store the first and second largest numbers. The following algorithm will be used: