0

Hey guys, Now that the previous problem was fixed I was finally able to run my program but now I just don't know what is wrong. Everytime I would enter in a few numbers and let it run, it would print out a series of the same number. Can someone tell me what is wrong this time? I cannot seem to get the right minimum, maximum, range, mean and median of the numbers i entered.

```
#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
//Constant for the array size
const int SIZE = 100;
//Declare variables
int values[SIZE];
int count = 0;
int index;
int number;
double lowest, highest, range, average, median, even, odd;
double total = 0;
//Information for the user
cout << "For this program, you will be asked to enter values (up to 100 values) that will be calculated." << endl;
cout << "for the minimum, maximum, range, mean, and median of the values." << endl;
//Get values from user and have sentinel value for when user would like to quit.
cout << "Enter a value or -1 to quit." << endl;
cin >> number;
//If sentinel is not given continue with input.
while (number != -1 && count < SIZE )
{
values[count] = number;
count = count + 1;
//ask for next
cout << "Enter a value or -1 to quit." << endl;
cin >> number;
}
//Find the minimum value from the set
lowest = values[0];
//the for loop
for (index = 1; index < SIZE; ++index)
{
if (values[index] < lowest)
{
lowest = values[index];
}
}
//Find the maximum value from the set
highest = values[0];
//the for loop
for (index = 1; index < SIZE; ++index)
{
if (values[index] > highest)
{
highest = values[index];
}
}
//Find range of set value
range = highest - lowest;
//Find mean
for (index = 0; index < SIZE; ++index)
{
total = total + values[index];
}
average = total / SIZE;
//find median
//Put values in ascending order
for (index = 0; index < SIZE; ++index)
{
cout << values[index] << endl;
}
if (index % 2 == 0)
{
even = index / 2;
median = ( ( even + 1 ) + even ) / 2;
}
else
{
odd = ( index / 2 );
median = odd + 1;
}
//Display outputs
cout << "The value set is: "<< endl;
for (index = 0; index < SIZE; ++index)
{
cout << values[index] << endl;
}
cout << "The minimum set is: "<< lowest << endl;
cout << "The maximum set is: "<< highest << endl;
cout << "The range set is: "<< range << endl;
cout << "The mean set is: "<< average << endl;
cout << "The median set is: "<< median << endl;
return 0;
}
```

*Edited
by pritaeas*: Moved to C++