1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
|
#include <iostream>
using namespace std;
double inputArray(double NUM[]);
double outputArray(double NUM[]);
double highNum(double NUM[], int numCount);
double lowNum(double NUM[], int numCount);
double findAverage(double NUM[], int numCount);
double range(int lowest, int highest);
double valuesAbove(double NUM[], int numCount, double average);
void userID();
int main()
{
const int numCount = 10;
double NUM[numCount], average;
int lowest, highest;
cout << "Enter numbers:\n" ;-
inputArray(NUM);
highNum(NUM, numCount);
cout << "The highest value is: " << highest << endl;
lowNum(NUM, numCount);
cout << "The lowest value is: " << lowest << endl;
range(lowest, highest);
findAverage(NUM, numCount);
cout << "Average of the ten values is: " << average << endl;
valuesAbove(NUM, numCount, average);
userID();
}
double inputArray(double NUM[])
{
cin >> NUM[0];
cin >> NUM[1];
cin >> NUM[2];
cin >> NUM[3];
cin >> NUM[4];
cin >> NUM[5];
cin >> NUM[6];
cin >> NUM[7];
cin >> NUM[8];
cin >> NUM[9];
outputArray(NUM);
}
double outputArray(double NUM[])
{
cout << "\nValues in data set" << endl;
cout << NUM[0] << " " ;
cout << NUM[1] << " " ;
cout << NUM[2] << " " ;
cout << NUM[3] << " " ;
cout << NUM[4] << " " ;
cout << NUM[5] << " " ;
cout << NUM[6] << " " ;
cout << NUM[7] << " " ;
cout << NUM[8] << " " ;
cout << NUM[9] << endl;
}
double highNum(double NUM[], int numCount)
{
int count;
int highest;
highest = NUM[0];
for (count = 1; count < numCount; count++)
{
if (NUM[count] > highest)
highest = NUM[count];
return highest;
}
}
double lowNum(double NUM[], int numCount)
{
int count;
int lowest;
lowest = NUM[0];
for (count = 1; count < numCount; count++)
{
if (NUM[count] < lowest)
lowest = NUM[count];
return lowest;
}
}
double findAverage(double NUM[], int numCount)
{
double total = 0;
double average;
for (int count = 0; count < numCount; count++)
total += NUM[count];
average = total / numCount;
return average;
} //find average
double range(int lowest, int highest)
{
cout << "Values used range from: " << lowest << " to " << highest << endl;
}
double valuesAbove(double NUM[], int numCount, double average)
{
int ct;
for (ct = 0; ct < numCount; ct += 1)
{
if (NUM[] > average)
{
cout << "Values above the average" << endl;
cout << NUM[];
}
}
}
void userID()
{
cout << "Lab7" << endl;
}
|