hey how do you find the minimum and maximum of entered numbers
suppose some one enters 5,4,9,2,3,1,7,8
and then find out the maximum and minimum from them
i have the program coded but I'm getting errors in the maximum number
the minimum number is fine but a wierd number appears in the highest numberCode:#include<iostream> #include<conio.h> using namespace std; int main() { const int SZ = 7; double sales[SZ]; int x; double lowest = sales[0]; double highest = sales[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 ( highest < sales[x] ) { 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(); }



LinkBack URL
About LinkBacks




