-
Help please!
I trying to write a program that finds the largest number from a known quantity of integers and also finds the smallest integer from a unknown quantity of integers.
These options should be acessed through a menu that looks like this:
A - Find the largest # with a known quantity of numbers
B - Find the smallest # with an unknown quantity of numbers
C - Quit
Please enter your choice ___
...and should repeat until the user choses option C
My problem is figuring out how to use a loop to find the largest and smallest integers in options A and B. I know that I have to cin the input values to a variable to compare it to the largest of the values entered but I having a hard time figuring it out. Any help would be greatly appreciated.
-
Why don't you post your try(s)? We aren't here to do your homework for you.
-
Well, I don't recall asking anyone to write the code for me. I was simply trying to see if anyone could give me insight on how to use a for loop to output the largest or smallest integer out of a certian quantity of numbers. I don't really have a complete "try" as I've been stuck on how to do this. I understand how to use the loop to find averages and sums, but this particular operation I'm not quite understanding. If this is the wrong place to be asking these questions please let me know or point me in the right direction.
-
Code:
declare number = 0;
for start to end {
if start {
number = index_value
}
if index_value > number { // looking for largest
number = index_value
}
}