getTotal Error for array

For some reason I cannot get this to run properly. It has something to do with the getTotal function apparently according to the error message.

This is the error message...
Error 1 error LNK2019: unresolved external symbol "int __cdecl getLowest(int const (* const)[4],int)" (?getLowest@@YAHQAY03$$CBHH@Z) referenced in function _main C:\Users\\Documents\Visual Studio 2010\Projects\2D Array Operations\2D Array Operations\2D Array Operations.obj
Error 2 error LNK2019: unresolved external symbol "int __cdecl getHighest(int const (* const)[4],int)" (?getHighest@@YAHQAY03$$CBHH@Z) referenced in function _main C:\Users\\Documents\Visual Studio 2010\Projects\2D Array Operations\2D Array Operations\2D Array Operations.obj
Error 3 error LNK2019: unresolved external symbol "int __cdecl getRowTotal(int const (* const)[4],int)" (?getRowTotal@@YAHQAY03$$CBHH@Z) referenced in function _main C:\Users\\Documents\Visual Studio 2010\Projects\2D Array Operations\2D Array Operations\2D Array Operations.obj
Error 4 error LNK1120: 3 unresolved externals C:\Users\\Documents\Visual Studio 2010\Projects\2D Array Operations\Debug\2D Array Operations.exe 1

Any help would be appreciated.

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 <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

char again;
const int COLS = 4;
const int ROWS = 3;

void showArray(const int[][COLS], int);
int getTotal(const int [][COLS]);
double getAverage(const int[][COLS]);
int getRowTotal(const int[ROWS][COLS], int);
int getColumnTotal(const int[ROWS][COLS], int);
int getHighest(const int[][COLS], int);
int getLowest(const int[][COLS], int);

int main()
{
	int a = 1;
	int table1[ROWS][COLS] = {{12, 11, 10, 9}, {8, 7, 6, 5}, {4, 3, 2, 1}};
	int total = 0;
	double average = 0;
	int rowTotal = 0;
	int columnTotal = 0;
	int highestRow = 0;
	int lowestRow = 0;
	
	do
	{
		total = getTotal(table1);
		average = getAverage(table1);
		rowTotal = getRowTotal(table1, a);
		columnTotal = getColumnTotal(table1, a);
		highestRow = getHighest(table1, a);
		lowestRow = getLowest(table1, a);

		cout << "The contents of table 1 are: \n";
		showArray(table1, ROWS);
		cout << "The total is: " << total << endl;
		cout << "the average is: " << average << endl;
		cout << "The total of row " << a + 1 << " is: " << rowTotal << endl;
		cout << "The total of column " << a + 1 << " is: " << columnTotal << endl;
		cout << "The highest amount in row " << a + 1 << " is: " << highestRow << endl;
		cout << "The lowest amount in row " <<  + 1 << " is: " << lowestRow << endl << endl;

		cout << "Do you want to run this program again? Y/N";
		cin >> again;
	} while (again == 'y' || again == 'Y');
		return 0;
}

void showArray(const int array[][COLS], int rows)
{
	for (int x = 0; x < rows; x++)
	{
		for (int y = 0; y < COLS; y++)
		{
			cout << setw(4) << array[x][y] << " ";
		}
		cout << endl;
	}
}

int getTotal(const int array[][COLS])
{
	int total = 0;
    
	for(int r = 0; r < ROWS; r++)
	{
       for(int c = 0; c < COLS; c++)
	   {
          total += array[r][c];
	   }
	}
	
	return total;
}

double getAverage(const int array[][COLS])
{
	double total = getTotal(array);

	return total / (ROWS * COLS);
}

int GetRowTotal(const int array[ROWS][COLS], int a)
{
	int sum = 0;

	for(int c = 0; c < COLS; c++)
	{
		sum += array[a][c];
	}

	return sum;
}

int getColumnTotal(const int array[ROWS][COLS], int a)
{
	int sum = 0;

	for(int r = 0; r < ROWS; r++)
	{
		sum += array[r][a];
	}

	return sum;
}

int getHighestRow(const int array[][COLS], int a)
{
	int highest = 0;

	highest = array[a][0];

	for(int c = 1; c < COLS; c++)
	{
		if(array[a][c] > highest)
		{
			highest = array[a][c];
		}
	}

	return highest;
}

int getLowestRow(const int array[][COLS], int a)
{
	int lowest = 0;

	lowest = array[a][0];

	for(int c = 1; c < COLS; c++)
	{
		if(array[a][c] < lowest)
		{
			lowest = array[a][c];
		}
	}

	return lowest;
}
Last edited on
int GetRowTotal(const int array[ROWS][COLS], int a)

int getRowTotal(const int array[ROWS][COLS], int a)

Notice the difference?
I noticed that after I submitted. Thanks.

Now I still get these errors...

Error 1 error LNK2019: unresolved external symbol "int __cdecl getLowest(int const (* const)[4],int)" (?getLowest@@YAHQAY03$$CBHH@Z) referenced in function _main C:\Users\\Documents\Visual Studio 2010\Projects\2D Array Operations\2D Array Operations\2D Array Operations.obj
Error 2 error LNK2019: unresolved external symbol "int __cdecl getHighest(int const (* const)[4],int)" (?getHighest@@YAHQAY03$$CBHH@Z) referenced in function _main C:\Users\n\Documents\Visual Studio 2010\Projects\2D Array Operations\2D Array Operations\2D Array Operations.obj
Error 3 error LNK1120: 2 unresolved externals C:\Users\n\Documents\Visual Studio 2010\Projects\2D Array Operations\Debug\2D Array Operations.exe 1
That could be because there is no getHighest or getLowest implementation in your code.

There is, however, a getHighestRow and getLowestRow.
Thanks! Solved.
Topic archived. No new replies allowed.