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?
Printable View
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?
What have you tried?
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....
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
Suppose I, being as generous as I am :p, 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?Quote:
but i couldn't get it determine which is the highest value i've entered and the lowest value.
waaaaaaaaa
should i manually count it???
huhuhu
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.
That is not the point. I am trying to get you to come up with an algorithm.Quote:
should i manually count it???
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.)
use for loop man
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
Ah, so that is what you mean by "manual": hardcoding the comparisons.
Yes, you should use a loop.
can a loop determine the highest and the lowest value i've input?
Whenever you need to do something repetitively some number of times, looping is always involved.
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.
Yes. As I noted, you already have an algorithm outlined to you that uses a loop to do what you want to do.Quote:
can a loop determine the highest and the lowest value i've input?
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!