Wrote this max min problem. The output however gives me the correct max but not the correct min. It simply returns 0 for the min everytime. Any ideas what I need to fix?
#include "stdafx.h"
#include <iostream.>
#include <conio.h>
using namespace std;
int main()
{
const int NUM_DAYS = 6;
double sales[NUM_DAYS];
int a;
double min = 0;
double max = 0;
for(a = 0; a <= NUM_DAYS; ++a)
{
cout<<"DEBUG: a is currently = " <<a;
cout<<"Enter sales value "<<a + 1<<" "<<endl;
cin>>sales[a];
}
for (a = 0; a <= 6; ++a)
{
if (max < sales[a]) max = sales[a];
else if (min > sales[a]) min = sales[a];
}
cout<<"The highest daily sales figure is: "<<max<<endl;
cout<<"The lowest daily sales figure is: "<<min<<endl;
getche();
}