First if I choose A it take the qty and the only number and shows it as the largest. I believe the smallest works correctly but not sure since I get a warning message about it. The warning messages I get are:

loop.cpp(67) : warning C4700: uninitialized local variable 'max' used
loop.cpp(79) : warning C4700: uninitialized local variable 'num' used
loop.cpp(85) : warning C4700: uninitialized local variable 'low' used

here is my code I have:

#include <iostream>

using namespace std;

double larger(double x, double y);
double smaller(double x, double y);

void greatestFunction(int qty);
void smallestFunction();

const int SENTINEL = -99;

int main()
{

	bool done;
	char letter;
	char a, b, c;
	int qty, count;
	double max, low, num;

	done = false;

	while (!done)
	{
		cout << "Please choose one of the following choices.\n"
			 << "A - Find the largest # with a known quantity of numbers\n"
			 << "B - Find the smallest # with an unknown quantity of numbers\n"
			 << "C - Quit" << endl;
		
		cout << "Please enter your choice: ";
		cin >> letter;
		cout << endl;
	
		if (letter == 'a')
		{
			cout << "Enter quantity of numbers: ";
			cin >> qty;
			count = qty;
			greatestFunction(qty);
		}
		if (letter == 'b')
		{
			cout << "Enter a number, to stop enter -99: ";
			cin >> num;
			low = num;
			smallestFunction();
		}
	if (letter == 'c')
	{
		done = true;
	}
	}
	return 0;
}
void greatestFunction(int qty)
{
	int max;
	int num;
	bool done;
	
	int greatest(int qty);
		for (int count = 1;count > qty;count++)
		{
			cout << "Enter " << qty << " numbers: ";
			cin >> num;
			max = larger(max, num);                // Line 67 warning
			done = false;
		}
		cout << "The largest number is: " << max << endl;
}
void smallestFunction()
{
	int low;
	int num;
	bool done;

	int smallest();
		while (num != SENTINEL)                        //Line 79 warning
		{
			cout << "Enter a number, to stop enter -99: ";
			cin >> num;
			if (num != SENTINEL)
			{
				low = smaller(low, num);        //Line 85 warning
			}
		}
		cout << "The smallest number is: " << low << endl;
		done = false;
}
double larger (double x, double y)
{
	if (x >= y)
		return x;
	else
		return y;
}
double smaller (double x, double y)
{
	if (x <= y)
		return x;
	else
		return y;
}

It's saying you haven't initialized your variables, but you're trying to access their value.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.