# Can't find the lowest number in array?

This is a discussion on Can't find the lowest number in array? within the C++ Programming forums, part of the General Programming Boards category; With the following code I found the highest number in each array but it only returns the first number in ...

1. ## Can't find the lowest number in array?

With the following code I found the highest number in each array but it only returns the first number in each array for the lowest and not the lowest number. Could someone please tell me why?#include <iostream>
#include <iomanip>
using namespace std;

double FindHighest( double [], const int );
double FindLowest( double [], const int );

int main()
{
double x[] = { 11.11, 66.66, 88.88, 33.33, 55.55 };
double y[] = { 9, 6, 5, 8, 3, 4, 7, 4, 6, 3, 8, 5, 7, 2 };
double z[] = { 123, 400, 765, 102, 345, 678, 234, 789 };

cout << fixed << setprecision(2);

double high1 = FindHighest (x, sizeof (x) / sizeof (x[0]));
double high2 = FindHighest (y, sizeof (y) / sizeof (y[0]));
double low1 = FindLowest (x, sizeof (x) / sizeof (x[0]));
double low2 = FindLowest (y, sizeof (y) / sizeof (y[0]));

cout << "Array x: high = " << high1 << " low = " << low1 << '\n';
cout << "Array y: high = " << high2 << " low = " << low2 << '\n';
cout << "Array z: high = " << FindHighest (z, sizeof (z) / sizeof (z[0]))
<< " low = " << FindLowest (z, sizeof (z) / sizeof (z[0])) << '\n';
return 0;
}

double FindHighest( double num[], const int SZ )
{
int highest = num[ 0 ];

for( int i = 1; i < SZ; i++ )
{
if( highest < num[ i ])
highest = num[ i ];
}
return highest;
}

double FindLowest( double num[], const int SA )
{

int highest = 0;

double lowest = num[ highest ];

for( int i = highest; i > SA; i++ )
{
if( lowest > num[ i ])
lowest = num[ i ];

}
return lowest;
}