So im trying to display the largest value entered and the smallest value entered. i can get my code to compile and run the largest number if its greater than o and the smallest number if its less than 0. but i want to be able to cover all numbers entered. Positive and Negative. Does anyone have any sugestions.
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
//Declarations
int intArray[10];
double dbltotal = 0.0;
double dblaverage = 0.0;
double dblmax = 0.0;
double dblmin = 0.0;
//Input and Process
for (int x=0; x<10; x++){
cout << "Enter a number: ";
cin >> intArray[x];
dbltotal = dbltotal + intArray[x];
if (intArray[x] > dblmax)
dblmax = intArray[x];
if (intArray[x] < dblmin)
dblmin = intArray[x];
}
dblaverage = dbltotal / 10.0;
//Output
cout << "The sum of the numbers entered is " << dbltotal << endl;
cout << "The average of the numbers entered is " << dblaverage <<endl;
cout << "The max number entered was: " << dblmax << endl;
cout << "The minimum number entered was: " << dblmin << endl;
system ("pause");
return 0;
}