User Defined Function - unresolved external

Why does this program not get built? I'm just learning how to do user defined functions, and menu() on it's own works, but I need to get the greatest() to work and it will not build.

I do not understand what syntax i am missing. please help.

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
#include <iostream>
#include <cmath>
#include <Windows.h>
#include <string>

using namespace std;

void menu ();
double greatest(double& max);


int main()
{
	// declaring & initializing variables
	char selection;
	double max, currentLarge;
	double currentSmall = 100;
	

	// do loop for application running
	do
	{
		menu();
		cin >> selection;
		cout << endl;
		switch(selection)
		{
		case 'A':
		case 'a':
			cout << "You have selected: " << selection << ". How many numbers would you like to enter?\n";
			cin >> max;
			currentLarge = greatest(max);
			cout << "The largest number you entered was " << currentLarge << ".\n\n";
			break;
		case 'B':
		case 'b':
			
			break;
		}
	}
	while((selection != 'C')  || (selection != 'c') );
	return 0;
}




void menu()
{
	// Menu display
		cout << "Welcome to the Menu Program for Week 4. Please select one of the three options below.\n";
		cout << "A - Find the Largest Number with a known quantity of Numbers.\n";
		cout << "B - Find the Smallest Number with a known quantity of Numbers.\n";
		cout << "C - Quit.\n\n";
		cout << "Please enter your selection: ";
		cout << endl;
}

double greatest(double& max)
{	
	double count = 1;
	double currentLarge;
	double nextNum;
	
			do
			{
				cout << "Enter a number: ";
				cin >> nextNum;
				count++;
				if (nextNum > currentLarge)
					currentLarge = nextNum;
			}
			while(count <= max);
	return (currentLarge);
}
Last edited on
currentLarge is not initialized in line 62, though I would try to find a way to not set it to zero.

Also, line 41, need to be an && condition, not || to actually quit the loop.

Last edited on
there is no need for the formal argument double & max just do double max .
thank you both very much, the information allowed me to conquer a lot more of this concept. much appreciated!
Topic archived. No new replies allowed.