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