I can't find two errors.

My program looks like it should run perfectly fine, however there are two linker errors that I cannot figure out. The first is that there is one unresolved external, the second is that main is referenced in function. If you guys could figure out where these errors are coming from, that would be great.

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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
#include <iostream>
#include <iomanip>
#include <cmath>
using std::cout;
using std::cin;
using std::endl;
using std::setw;

int GetData();
void DisplayMenu(int & menuChoice);
void ProcessMenuChoice(int menuChoice, int & userNumber);
void IsPosNeg(int userNumber);
void IsOddEven(int userNumber);
double FindSqrt(int userNumber);
int FindNumDigits(int userNumber);
int FindDigitAtPosition(int userNumber, int specificDigit);
void DisplayAdditionTable();
void DisplayMultiplicationTable();

int main()
{
	int menuChoice = 0;
	int userNumber = 0;
	char userChoice = '\0';


	cout << "\t\t###NUMBER MANIPULATOR PROGRAM###\n" << endl;

	do
	{
		userNumber = GetData();

		DisplayMenu(menuChoice);

		ProcessMenuChoice(menuChoice, userNumber);

		cout << "Would you like to enter another number? (y/n): ";
		cin >> userChoice;

		cout << '\n' << endl;

	} while (userChoice == 'y' || userChoice == 'Y');

	cout << "\t\t###END OF PROGRAM###\n" << endl;

	return 0;
}

int GetData()
{
	int userNumber = 0;

	cout << "Please enter a number: ";
	cin >> userNumber

	while (userNumber < -1000000 || userNumber > 1000000)
	{
		cout << "\n\nYour value is too big or too small, please try again. ";
		cin >> userNumber;
	}

	return userNumber;
}

void DisplayMenu(int & menuChoice)
{
	cout << "\n\n1) Is the number odd or even?\n"
		<< "2) Is the number positive or negative?\n"
		<< "3) What is the square root of the number?\n"
		<< "4) How many digits are in the number?\n"
		<< "5) Display a certain digit in the number.\n"
		<< "6) Display an addition table for the numbers 1 to 12\n"
		<< "7) Display a multiplication table for the numbers 1 to 12\n"
		<< endl;

	cout << "Enter a menu choice: ";
	cin >> menuChoice;

	while (menuChoice < 1 || menuChoice > 7)
	{
		cout << "\n\nInvalid entry, please try again. ";
		cin >> menuChoice;
	}

	cout << '\n' << endl;
}

void ProcessMenuChoice(int menuChoice, int & userNumber)
{
	double sqrtNumber = 0;
	int numberOfDigits = 0;
	int specificDigit = 0;

	switch (menuChoice)
	{
	case 1:
		IsOddEven(userNumber);
		break;

	case 2:
		IsPosNeg(userNumber);
		break;

	case 3:
		sqrtNumber = FindSqrt(userNumber);

		cout << "The square root of you number is " 
			<< sqrtNumber << '\n' << endl;
		break;

	case 4:
		numberOfDigits = FindNumDigits(userNumber);

		cout << "The number of digits in your number is " 
			<< numberOfDigits << '\n' << endl;
		break;

	case 5:
		specificDigit = FindDigitAtPosition(userNumber, specificDigit);

		cout << "The digit you wanted is " << specificDigit << '\n' << endl;
		break;

	case 6:
		DisplayAdditionTable();
		break;

	case 7:
		DisplayMultiplicationTable();
	}

	cout << '\n' << endl;
}

void IsOddEven(int userNumber)
{
	int remainder = userNumber / 2;

	if (userNumber == 0)
		cout << "\n\nYour number is zero.\n" << endl;
	else if (remainder == 0)
		cout << "\n\nour number is Even.\n" << endl;
	else
		cout << "\n\nYour number is Odd.\n" << endl;
}

void IsPosNeg(int userNumber)
{
	if (userNumber > 0)
		cout << "\n\nYour number is Positive.\n" << endl;
	else if (userNumber < 0)
		cout << "\n\nYour number is Negative.\n" << endl;
	else
		cout << "\n\nYour number is Zero.\n" << endl;
}

double FindSqrt(int userNumber)
{
	double sqrtNumber = 0;

	sqrt_number = sqrt(userNumber);

	cout << "\n\nThe square root of your number is " << sqrt_number << '\n' << endl;

	return sqrtNumber;
}

int FindNumDigits(int userNumber)
{
	for (int digit = 1; userNumber > 0; digit++)
	{
		userNumber /= 10;
		numberOfDigits = digit;
	}

	return numberOfDigits;
}

int FindDigitAtPosition(int userNumber, int specificDigit)
{
	int userDigit = 0;

	cout << "\n\nWhich digit position do you want? ";
	cin >> userDigit;

	for (int a = 1; a <= userDigit; a++)
	{
		specificDigit = userNumber % 10;
		userNumber /= 10;
	}

	return specificDigit;
}

void DisplayAdditionTable()
{
	int topRow = 0;
	int topLine = 0;
	int rowVar = 0;
	int displayRow = 0;

	cout << setw(5) << " ";

	while (topRow <= 12)
	{
		cout << setw(2) << topRow << " ";
		topRow++;
	}

	cout << endl;
	cout << "------";

	while (topLine <= 12)
	{
		cout << "---";
		topLine++;
	}

	cout << endl;

	for (int col = 0; col <= 12; col++)
	{
		cout << setw(2) << col << " " << '|' << " ";
		for (int row = 0; row <= 12; row++)
		{
			displayRow = rowVar + row;
			cout << setw(2) << displayRow << " ";
		}
		rowVar++;
		cout << endl;
	}
}

void DisplayMultiplicationTable()
{
	int topRow = 0;
	int topLine = 0;
	int rowVar = 0;
	int displayRow = 0;

	cout << setw(5) << " ";

	while (topRow <= 12)
	{
		cout << setw(3) << topRow << " ";
		topRow++;
	}

	cout << endl;
	cout << "--------";

	while (topLine <= 12)
	{
		cout << "----";
		topLine++;
	}

	cout << endl;

	for (int col = 0; col <= 12; col++)
	{
		cout << setw(2) << col << " " << '|' << " ";
		for (int row = 0; row <= 12; row++)
		{
			displayRow = rowVar * row;
			cout << setw(3) << displayRow << " ";
		}
		rowVar++;
		cout << endl;
	}
}
This code has compilation errors (wrong variable names) but no linking errors if I correct the names.
Thx! It is fixed and running smoothly.
Topic archived. No new replies allowed.