# Thread: Unlimited Inputs and Determines which is greatest and lowest

1. ## Unlimited Inputs and Determines which is greatest and lowest

Enter how many numbers: 10 (may vary)

1
2
3
4
5
6
7
8
9
10

The highest number is 10.
The lowest number is 1.

can someone help me with these?

2. What have you tried?

3. i have tried to input 10 numbers for example but i couldn't get it determine which is the highest value i've entered and the lowest value....

4. Right, the way it works here is that you TRY something, then ask for help showing what you have done in the source code.

--
Mats

5. but i couldn't get it determine which is the highest value i've entered and the lowest value.
Suppose I, being as generous as I am , give you a bag of coins and ask you to find the largest (or smallest) denomination (value) among the coins. How would you do it?

6. waaaaaaaaa
should i manually count it???
huhuhu

7. Create a couple variables to store the highest and lowest values. Initialize the "high" variable to an extremely small value and update it if necessary as you enter in each new value... if the new value entered is more than what is already stored, then change the "high" variable to match the current new value. Do something similar for the "low" variable, initialize it to something really high and then keep testing/comparing it against the new values being entered and update if needed. It's really simple.

8. should i manually count it???
That is not the point. I am trying to get you to come up with an algorithm.

hk_mp5kpdw has provided you with a possible algorithm, though personally I do not find it intuitive. (When we compare stuff, we typically do not start by comparing the first item with some imaginary extreme value. Rather, we start by comparing the first item with the second item.)

9. use for loop man

10. is looping involve in this?

i know how to display the highest and the lowest but in a limited manner

for example 10 items,

will i could get it since i could manually compare the 1st number up to the last

but with 100 items hehehehe i could still manually do that but im looking for a better program

which could easily compare the highest and the lowest

11. Ah, so that is what you mean by "manual": hardcoding the comparisons.

Yes, you should use a loop.

12. can a loop determine the highest and the lowest value i've input?

13. Originally Posted by omarbags
is looping involve in this?
Whenever you need to do something repetitively some number of times, looping is always involved.

Originally Posted by omarbags
i know how to display the highest and the lowest but in a limited manner

for example 10 items,

will i could get it since i could manually compare the 1st number up to the last

but with 100 items hehehehe i could still manually do that but im looking for a better program

which could easily compare the highest and the lowest
The main idea here is to deal with largest-so-far and the current number. Is the current number we're looking at right now the largest number? If so, make a note. If not, we don't care.

14. can a loop determine the highest and the lowest value i've input?
Yes. As I noted, you already have an algorithm outlined to you that uses a loop to do what you want to do.

15. in which case should i look and focus to be able to run the program correctly?
c'mon guys a little bit of help here....
i know you are all genius!
just a little clue further hehehe!