I need help here can someone be of assistance.

I am getting an error "59|undefined reference to `add_values()'|"

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
131
132
133
134
135
136
137
138
139
140
141
142
143
  #include <cstdlib>

using namespace std;

void display_menu (void);

void add_values ();

void edit_value ();

void print_value();

void display_stats();

void exit_program(void);

int user_num[10] = {0};

int user_input;

int main()
{
   cout << "Hello, please select an option from the list below. 10 numbers are necessary to end this program." << endl;

   display_menu();

   return 0;
}

void display_menu(void)
{
    while((user_input > -999) || (user_input < 999))
        {

    char Add;

    char Edit;

    char Print;

    char Display;

    char Exit;

    cout << "(Add) Add a value" << endl;

    cout << "(Edit) Edit a value" << endl;

    cout << "(Print) Print a value" << endl;

    cout << "(Display) Display Statistics" << endl;

    cout << "(Exit) Quit the program" << endl;

    if (cin >> Add)
    {
        add_values ();
    }

    if (cin >> Edit)
    {
        edit_value();
    }

    if (cin >> Print)
    {
        print_value();
    }

    if (cin >> Display)
    {
        display_stats();
    }

    if (cin >> Exit)
    {
        exit_program();
    }

    }
    return;
}


void add_values (float stored_values [10])
{
    cout << "Please add 10 numbers between 999 to -999.";

    cin >> user_input;

    user_input = user_num[10];

}

void edit_value(float stored_values [10], int element_to_change)
{
    cout << "Please select a value to edit by typing user_num [and in here a number from 0 to 9] thank you" << endl;

}

void print_value (float stored_values [10])
{
    cout << user_num[0] << endl;
    
    cout << user_num[1] << endl;
    
    cout << user_num[2] << endl;
    
    cout << user_num[3] << endl;
    
    cout << user_num[4] << endl;
    
    cout << user_num[5] << endl;
    
    cout << user_num[6] << endl;
    
    cout << user_num[7] << endl;
    
    cout << user_num[8] << endl;
    
    cout << user_num[9] << endl;
}

void display_stats (float stored_values [10])
{
    int total;

    total = ((user_num[0] + user_num[1] + user_num[2] + user_num[3] + user_num[4] + user_num[5] + user_num[6] + user_num[7] + user_num[8] + user_num[9])/10);

    cout << "Displaying array elements" << endl;

    cout << "The average is" << total << endl;
    
    
}

void exit_program (void)
{
    cout << "Thank you and have a nice day.";

    return;
}
Last edited on
Well... where do you define your add_values function? Line 9 is only a function prototype. What actually happens inside that function?
Last edited on
add_values (); doesn't have a body
I added the full code and add_values (); is supposed to allow the user to add numbers to the array that can later be edited in the second function edit
Line 9 declares this function:
void add_values ();
and line 55 calls it, but line 85 defines this one:
void add_values (float stored_values [10])

In C++ these are different functions that share the same name. But you haven't defined the one that is called. I suspect that you need to change lines 9 and 55 to refer to the function at line 85.

All the other functions seem to be the same. You need to declare them, call them, and define them the same way.
Topic archived. No new replies allowed.