Hi everyone and thanks for looking to help me. I am working with a program involving arrays. I needed to write one that involves the use to
have the program take
about 10 numbers, list the minimum, the maximum, and the average.
Now the program that I have below runs fine which finds the average. But when I try to loop the program to find the minimum and maximum numbers it just repeats.
How do I loop in a loop to find the minimum and maximum nubers.
Please let me know. TY
#include
using namespace std;
const int arraymax = 10;
typedef int arraytype[arraymax];
float findaverage(arraytype numarray, int count);
void array2(arraytype numarray, int & count);
int main(void)
{
int array1;
arraytype array3;
float avg;
array2(array3, array1);
avg = findaverage(array3, array1);
cout << endl << "The average is: " << avg << endl << endl;
return 0;
}
void array2(arraytype numarray, int & count)
{
int k;
cout << "How many numbers would you like to enter? ";
cin >> count;
for (k = 0; k < count; k++)
{
cout << "Enter your numbers " << k << " ";
cin >> numarray[k];
}
}
float findaverage(arraytype numarray, int count)
{
int k;
float sum;
sum = 0.0;
for (k = 0; k < count; k++)
sum=sum + numarray[k];
if (count > 0)
return sum / count;
else
return 0.0;
}