#include <iostream>
using namespace std;
int smallest(int array[], int size)
{
int a = 0;
if (size ==1)
{
return array[0];
}
else
{
for (int i = 0; i < size; i++)
{
if (array[i] < array[i+1]) // 'if' needs to be lowercase. also, value is messed up
// because it traverses off the end of the array with (i+1)
{
a = array[i];
}
else
{
a = array[i+1];
}
}
/*
if (i = 10) then // this isn't working because it is outisde of the loop,
// but you don't need it.
{
return a;
}
*/
return a; // just return a when the loop finishes, you don't need an if statement
}
}
int main()
{
int array[10]={-1, 5, -23, 90, 4, 5, 6, -2, -100, 9};
cout<<smallest(array, 10);
system("pause");
return 0;
}