#include <iostream>
usingnamespace std;
constint SENTINEL = -999;
int main()
//set variables
{
int highnum;
int lownum;
int limit;
char choice;
int counter;
int num;
//iniatilize v ariables
highnum = -999;
lownum = 999;
cout<< "A - Find the largest number with a known quantity of numbers. ";
cout<< endl;
cout<< "B - Find the smallest number with an unknown quantity of numbers. ";
cout<< endl;
cout<< "C - Quit";
cout<< endl;
cout<< "Enter your choice. ";
cin>> choice;
cout<< endl;
switch (choice)
{
case'a':
case'A':
cout << " How many numbers would you like to compare? ";
cin >> limit;
cout<< "Enter your number ";
cin >> num;
dowhile (counter = 1);
while (counter <= limit);
while(counter ++)
if (num > highnum)
int highnum(num);
cout << "your highest number was ";
cout << highnum;
cout<< endl;
}
switch(choice)
case'b':
case'B':
{
num = 0;
num > SENTINEL;
cout << "Enter your numbers ending with ";
cout<< SENTINEL ;
cout << endl;
cin >> num;
if (num > lownum)
int lownum (num);
cout<< "Your lowest number was ";
cout << lownum;
cout<< endl;
}
switch (choice)
case'c':
case'C':
cout << "thank you for playing. " << endl;
cin.get();
cin.get();
return (0);
}
while (counter = 1);
while (counter <= limit);
while(counter ++)
what is this for? they are 3 separate loops that will run forever.
second
1 2
if (num > highnum)
int highnum(num);
what in the world could that possibly do?. redeclaring int highnum as a function within main that requires and int? fix this please. int lownum (num);fix this also
last error i got right of the bat was
1 2 3
num = 0;
num > SENTINEL;
what are you doing here? that is a Boolean operator that returns true or false depending on size. this will do exactly nothing.
For the first it give me a excepted a while for the various parts if I try and make them one line. The point of the program in to return either the highest or lowest number in a user entered list. with the first A choice having a user defined limit and the b choice being SENTINEL controlled.
That still will not loop and only runs once then exits for my a choice and still leaves choice b not working. I do appreciate the help. I am using visual studio for a compiler and have no idea what i am doing in C++
Ok so I am trying to go at this slightly different than above. This is just the first step to the program still trying to figure out the second step. Having a slight issue with the function headers saying the need a declaration.
the commented variables are just there for the second menu option I have yet to code.
usingnamespace std;
#include <iostream>
#include <cctype>
usingnamespace std;
int main;
//int low (low = 999);
//const int SENTINEL = -9999;
int menu;
{
int choice();
for (menu);
cout<<"Select a chioce from the menu below.";
cout<<" A- Find the highest number in a series. ";
cout<<" B- find the lowest number in a series. ";
cout<<"C- Exit ";
cout<< "Enter your selection ";
cin>> choice;
if choice = a
do OptA
}
int OptA;
{
int number()
int limit;
int high (high = -999);
int counter = 0;
cout<<"how many number would you like to compare? ";
cin>>limit;
cout<<"Enter your numbers. ";
cout<< endl;
cin>>number;
if (number > high);
int high = number;
int counter = counter + 1;
while counter < limit;
else cout<< "The highest number is " << high);
cout<< endl);
return(menu);
}
#include <iostream>
int menu();
int OptA();
int main(){
//stuff here
return 0;
}
int menu(){
//stuff here
returnint;
}
int OptA(){
//stuff here
returnint;
}
#include <iostream>
#include <cctype>
usingnamespace std;
int main();
// PLACE HOLDERS FOR TESTING ONE SECTION AT A TIME.
//int low (low = 999);
//const int SENTINEL = -9999;
int menu();
//Trying to get a repeatable menu option
{
int choice();
for (menu);
cout<<"Select a chioce from the menu below.";
cout<<" A- Find the highest number in a series. ";
cout<<" B- find the lowest number in a series. ";
cout<<"C- Exit ";
cout<< "Enter your selection ";
cin>> choice;
if (choice = a)
do OptA
if (choice = b)
do OptB
if (choice = c)
do OptC
returnint;
}
//this option should output only the highest number for a usre defined limit to end the loop. Then return to menu.
int OptA();
{
int number()
int limit;
int high (high = -999);
int counter = 0;
cout<<"how many number would you like to compare? ";
cin>>limit;
cout<<"Enter your numbers. ";
cout<< endl;
cin>>number;
if (number > high);
int high = number;
int counter = counter + 1;
while (counter < limit);
else cout<< "The highest number is " << high);
cout<< endl);
returnint;
}
// OptB should output the lowest number entered with a sentinel value ending the loop. Then return to menu
// OptC exits the program.