how do you find the minimum and maximum number from a given set of numbers without sorting them
?
i have the code but the it isnt working properly
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
const int SZ = 7;
double sales[SZ];
int x;
double lowest = 0;
double highest = 0;
for(x = 0; x < SZ; x++)
{
cout<<"Enter sales for day "<<(x + 1)<<" >> ";
cin>>sales[x];
}
cout<<"The entered sales are: ";
for(x = 0; x< SZ; x++) {
cout<<sales[x]<<" ";
}
for ( int x = 0; x < SZ; x++ ) {
if ( sales[x] > highest ) {
highest = sales[x];
}
}
for ( int x = 0; x < SZ; x++ ) {
if( sales[x] < lowest ) {
lowest = sales[x];
}
}
cout<<"\nThe lowest sale is "<<lowest<<endl;
cout<<"\nThe highest sale is "<<highest<<endl;
getch();
}
the highest number is working fine the lowest number im getting errors on it
it shows a weird number please help