functions won't work, please help!


I'm not good with arrays, or functions for that matter, and i can't seem to make this program work, please help! any advice is nice
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
 /*
Name: Nick Banney
Date: 4/22/2014
Program Name: Olympic Gymnastics Score Calculations
Function: At the Olympics, in an effort to limit individual biases, the score
earned for a routine is calcuated by first throwing the low score and high score
before calculating the average from the slate of judges. A medal-winning score
is usually above a 15.0. The purpose of this program is to take in the judges
ratings, throw out the low and high score and then do the math to find the 
average after the high and low scores are thrown out.

The program uses two functions.  One to find the smallest element
and where it is in an array, the other to find the largest element and where
it is in the array.
*/

#include <iostream>
#include <iomanip>
// Include any other header files you may need.

const int ARRAY_SIZE = 6;

// Include here the function prototypes remembering that the formal parameter list
// should not include names of variables declared in the main function.

using namespace std;
int indexlowscore(double score[ARRAY_SIZE]);
int indexhighscore(double score[ARRAY_SIZE]);

int main()
{
	double ratings[ARRAY_SIZE] = {15.250, 15.900, 14.775, 14.995, 15.750, 15.100};  // This is the array that needs to be passed to the functions.
			// This array contains the scores given by the team of judges.
	indexlowscore(ratings);
	indexhighscore(ratings);
	int indexL, indexH;  //These integers are the index values that need to be returned from the functions.
	double average, sum = 0; // This will hold the average of the scores after the array has been modified by the functions.
	double scores[ARRAY_SIZE];
	
	// Insert here statements to output the ratings array to the console with user friendly formatting:


	cout << "The ratings array is passed to the first function which will find the" << endl
		<< "lowest value in the array and where it is located in the array using its \nindex value." << endl
		<< "The lowest value will be replaced with a 0 and the array and index will \nbe returned." << endl << endl;

	// Insert here the call to the functionOne that performs the stated operation on the array:
	indexL = indexlowscore(scores);

	cout << "The ratings array is passed to the second function which will find the" << endl
		<< "highest value in the array and where it is located in the array using its index value." << endl
		<< "The highest value will be replaced with a 0 and the array and index will \nbe returned." << endl << endl;

	// Insert here the call to the functionTwo that performs the stated operation on the array:
	indexH = indexhighscore(scores);
	
	// *******************************
	
	for(int i=0; i<ARRAY_SIZE; i++)  // This FOR statement sums the elements of the array.
		{
			sum = sum + ratings[i];
			sum = sum - (indexL + indexH);
		}
	average = sum/(ARRAY_SIZE-2);  // Here the average is calculated.

	// ******************************

	// Insert here statements to output the following information to the console in the following format:
	// 1) Output with user friendly formatting, the average calculated for the judges' score after the low
	//		value and high value have been set to zero.
	// 2) Output with user friendly formatting, the index value found for where the lowest value was in the
	//		array.
	// 3) Output with user friendly formatting, the index value found for where the highest value was in the
	//		array.
	cout << "The average for the judges' score, minus the lowest and highest value is " << average << endl;
	cout << "The index value for the lowest score was " << indexL << endl;
	cout << "The index value for the highest score was " << indexH << endl;

	cout << "ALL DONE!" << endl;

	return 0;
}

// Type in function definitions here:
int indexlowscore(double score[ARRAY_SIZE])
{
	double low, index;
	int i;
	low = score[0];
	for(int i = 0; i <ARRAY_SIZE; i++);
		{
			if(score[i]<low)
			{
				low = score[i];
				index = i;
			}
		}
	cout << "The lowest score from the judges panel was: " << index;
	return 0;
}


int indexhighscore(double score[ARRAY_SIZE])
{
	double high, index;
	int i;
	high = score[0];
	for(int i = 0; i <ARRAY_SIZE; i++);
		{
			if(score[i]>high)
			{
				high = score[i];
				index = i;
			}
		}
	cout << "The highest score from the judges panel was: " << index;
	return 0;
}
Please explain the int i; in lines 88 and 106
(¿why did you put that there?)


> and i can't seem to make this program work,
¿do you really think that you have described your problem?
Topic archived. No new replies allowed.