Undefined reference to array function

Write your question here.
I have these four functions and as far as i can tell they all line up with arguments. What am I missing?
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

#include <iostream>
#include <iomanip>
#include <cstring>

using namespace std;

int buildQuizArray(int);
void printArray( string, int, int);
double calcQuizAverage( int, int);
void sortArray( int, int);

/**********************************************************************
Function: int buildQuizArray( int quizArray[] )

Use: This function builds the array.

Arguments: The to be built array

Returns: The number of quiz scores
**********************************************************************/
int buildQuizArray( int quizArray[] )
    {
    int numSlots;
    int val;
    int i = 0;
    cout << "Enter a quiz score: ";
    cin >> val;
    while (val != -1)
        {
        quizArray[i] = val;
        i++;
        cout<< "Enter a quiz score";
        cin >> val;
        }
    return i+1;
    }

/**********************************************************************
Function: void printArray( string reportTitle, int quizArray[], int numberOfQuizzes )

Use: This function prints out the array

Arguments: The report title, the array, and the number of quizzes

Returns: Void
**********************************************************************/       
void printArray( char reportTitle[], int quizArray[], int numberOfQuizzes )
    {
    int i;
    cout<< reportTitle << "\n-----------\n";
    for (i=0; i<numberOfQuizzes; i++);
        cout<< "Quiz " << i <<":    " << setw(2) <<quizArray[i] <<"/10\n";
    }

/**********************************************************************
Function: double calcQuizAverage( int quizArray[], int numberOfQuizzes )

Use: This function calculates the quiz average

Arguments: The array and the number of quizzes

Returns: The average score
**********************************************************************/       

double calcQuizAverage( int quizArray[], int numberOfQuizzes )
    {
    int sumLow, sum = 0, i=0;
    double avg;
    sumLow = quizArray[0] + quizArray[1];
    for (i=0; i< numberOfQuizzes; i++)
        sum += quizArray[i];
    if (numberOfQuizzes <= 2)
        avg = sum / (10 * numberOfQuizzes) * 100;
    else 
        (sum - sumLow) / (10 * (numberOfQuizzes - 2)) * 100;
    return avg;
    }

/**********************************************************************
Function: void sortArray( int quizArray[], int numberOfQuizzes )

Use: This function sorts the array by number

Arguments: The array and the number of quizzes

Returns: The average score
**********************************************************************/    
void sortArray( int quizArray[], int numberOfQuizzes )
    {
    int i, j, min;
    int temp;
    for (i=0; i<numberOfQuizzes; i++)
        min = i;
        for(j=i+1; j<numberOfQuizzes; i++)
            {
            if (quizArray[i] < quizArray[min])
                min = j;
            }
        temp = quizArray[i];
        quizArray[i]=quizArray[min];
        quizArray[min]=temp;
    }
    
int main ()
{
    char str[20] = "Quiz Scores";
    int numberOfQuizzes, quizArray[12];
    double value;     
    numberOfQuizzes = buildQuizArray(quizArray[numberOfQuizzes]);
    sortArray(quizArray[12], numberOfQuizzes);
    value = calcQuizAverage(quizArray[12], numberOfQuizzes);
    cout << value;
    printArray(str, quizArray[12], numberOfQuizzes);

return 0;
}

look at line 8 and line 110.
as far as i can tell they all line up with arguments

No they do not.

1
2
3
4
5
6
7
8
9
10
11
int buildQuizArray(int);
int buildQuizArray( int quizArray[] )

void printArray( string, int, int);
void printArray( char reportTitle[], int quizArray[], int numberOfQuizzes )

double calcQuizAverage( int, int);
double calcQuizAverage( int quizArray[], int numberOfQuizzes )

void sortArray( int, int);
void sortArray( int quizArray[], int numberOfQuizzes )


None of your function prototypes match your implementations. THey must match exactly.


I didn't realize I needed int*
another thing:

(sum - sumLow) / (10 * (numberOfQuizzes - 2)) * 100;
This does nothing. In other words you aren't assigning the result to a variable.
Last edited on
Topic archived. No new replies allowed.