I need a program to find the largest number out of a known set of numbers for A (I got that part working correctly, and the smallest number for an unset amount of for B and C to quit, my problem is when it comes to B, I can't get it to show the smallest number, it'll always show 0 if it's not below -99, this is the code i got so far.
/code/
#include <iostream>
#include <string>
using namespace std;
int main()
{
string input;
int scanNum, bigNum = 0;
int i;
int enteredNum;
const int sentinel = -99;
cout << "Please enter one of the following. \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. \n" << endl;
cin >> input;
if (input=="A" || input=="a")
{
cout << "Please enter the amount of numbers you want to enter" << endl;
cin >> enteredNum;
for (i = 0; i < enteredNum; i = i++)
{
cin >> scanNum;
{
if (scanNum > bigNum)(bigNum = scanNum);
}
}
cout << "Your largest integer is " << bigNum << " . " << endl;
}
else if (input=="B" || input=="b")
{
scanNum = 999;
cout << "Please enter your numbers, end it by entering -99." << endl;
while (scanNum != -99)
{
cin >> scanNum;
if (scanNum != -99)
{ if (scanNum < bigNum)
{ scanNum = bigNum;
}
}
}
int main()
{
string input;
int scanNum, bigNum = 0;
int i;
int enteredNum;
const int sentinel = -99;
int newVar;
int smallNum = 1000;
cout << "Please enter one of the following. \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. \n" << endl;
cin >> input;
if (input=="A" || input=="a")
{
cout << "Please enter the amount of numbers you want to enter" << endl;
cin >> enteredNum;
for (i = 0; i < enteredNum; i = i++)
{
cin >> scanNum;
{
if (scanNum > bigNum)(bigNum = scanNum);
}
}
cout << "Your largest integer is " << bigNum << " . " << endl;
}
else if (input=="B" || input=="b")
{
scanNum = 999;
cout << "Please enter your numbers, end it by entering -99." << endl;
while (scanNum != -99)
{
cin >> scanNum;
if (scanNum != -99)
newVar = 999999999999999999;
if (scanNum != -99){newVar = scanNum;}
{ if (newVar < smallNum)
{ smallNum = newVar;
}
}
}
Nah, got a new problem, for some reason I can't get it to close now.
/code/
#include <iostream>
#include <string>
using namespace std;
int main()
{
string input;
int scanNum, bigNum = 0;
int i;
int enteredNum;
const int sentinel = -99;
int newVar;
int smallNum = 1000;
string input2;
while input!="C"
{
cout << "Please enter one of the following. \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. \n" << endl;
cin >> input;
if (input=="A" || input=="a")
{
cout << "Please enter the amount of numbers you want to enter" << endl;
cin >> enteredNum;
for (i = 0; i < enteredNum; i = i++)
{
cin >> scanNum;
{
if (scanNum > bigNum)(bigNum = scanNum);
}
}
cout << "Your largest integer is " << bigNum << " . " << endl;
}
else if (input=="B" || input=="b")
{
scanNum = 999;
cout << "Please enter your numbers, end it by entering -99." << endl;
while (scanNum != -99)
{
cin >> scanNum;
if (scanNum != -99)
newVar = 999999999999999999;
if (scanNum != -99){newVar = scanNum;}
{ if (newVar < smallNum)
{ smallNum = newVar;
}
}
}