We are required in our assignment to find the second smallest integer in one array recursively. However, for the sake of understanding the subject more, I want to do it iter
Try this ...
First condition checks if both values are less than value in array.
Second condition if value is less than small than smallest=element[i]
else secondSmallest=elements[i]
..
public static void main(String[] args)
{
int[] elements = {0 , 2 , 10 , 3, -3 };
int smallest = elements[0];
int secondSmallest = 0;
for (int i = 0; i < elements.Length; i++)
{
if (elements[i]