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?
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?
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
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
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
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?but i couldn't get it determine which is the highest value i've entered and the lowest value.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
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.
"Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
-Christopher Hitchens
That is not the point. I am trying to get you to come up with an algorithm.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.)
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
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.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
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.can a loop determine the highest and the lowest value i've input?
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
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!