Min, Max, Avg in an array

Hello again all seems I have been asking alot and I apologize but here is my situation and code

I need to get the min, max and average an array.

problem one: the users input the 20 incomes but when the cout line shows what they enter element 2 displays a number different then what was entered

problem two: the average is not computing properly and I can't see the problem

Problem three: NO idea how to get the min and max to show

#include <stdafx.h>
#include <iomanip>
#include <iostream>

using namespace std;

int main()
{
const int Num_Survey = 20;
int Income[Num_Survey];
int Input,
Input_sum = 0;
int temp,
pass,
limit;
double Input_avg,
Input_Max = 0,
Input_Min,
Input_Med;

cout << setprecision(1)
<< setiosflags(ios::fixed)
<< setiosflags(ios::showpoint);

cout << "please enter " << Num_Survey
<< " incomes from the survey " << endl << endl;

for (Input =0; Input < Num_Survey; ++Input)
{
cout << endl;
cout << " Enter income for Input" << Input +1 << ": $";
cin >> Income[Input];
}

cout << endl;
cout << "The incomes are ";
for (Input = 0; Input < Num_Survey; ++Input)
cout << setw(6) << Income[Input];

// bubble sort

limit = Num_Survey - 2;
for (pass = 1; pass <= Num_Survey - 1; ++pass)
{
for (Input = 0; Input <= Num_Survey; ++ Input)
if (Income[Input] < Income[Input + 1])
{
temp = Income[Input];
Income[Input] = Income[Input + 1];
Income[Input + 1] = temp;
}
--limit;
}

// Sorted Incomes

cout << endl << endl;
cout << "The incomes in decreasing order is:" << endl;
for (Input =0; Input < Num_Survey; ++Input)
cout << setw(6) << Income[Input];
cout << endl;

// Average
for (Input = 0; Input < Num_Survey; ++ Input)
Input_sum += Income[Input];
Input_avg = double(Input_sum) / Num_Survey;
cout << endl << endl;
cout << " the average income is $" << Input_avg << endl;

// Max

cout << " The Max Income reported is $" << Input_Max << endl;
system ("Pause");
return 0;
}
Topic archived. No new replies allowed.