#include <stdio.h>
int findSecondNumber(const int arr[], int size)
{
int BiggestNumber = 0;
int SecondNumber = 0;
if(size < 2)
{
printf("ERROR!\n");
return 0;
}
else
{
BiggestNumber = arr[0] > arr[1] ? arr[0] : arr[1];
SecondNumber = arr[0] < arr[1] ? arr[0] : arr[1];
}
for(int i = 2; i < size; i++)
{
if(arr[i] > BiggestNumber)
{
SecondNumber = BiggestNumber;
BiggestNumber = arr[i];
}
else
{
if(arr[i] > SecondNumber)
{
SecondNumber = arr[i];
}
}
}
return SecondNumber;
}
int main(void)
{
int array[10] = {-5, 8, 85, 80, 21, 90, 88, 80, 52, 5};
int value = 0;
value = findSecondNumber(array, sizeof(array)/sizeof(int));
printf("second value: %d\n", value);
return 0;
}