I know one way to get the maximum; you can get the minimum simultaneously, but the technique is the same in all languages. It is actually the same as you would use with pencil and paper. So let's have some numbers:

That program will produce a 100‑element array with numbers chosen between 1,000 and 2,000. Please read the details here otherwise you might get confused.
Now, using the first element (=1150) as a first guess, work out the algorithm as you go through the array. It is not difficult.
What do you mean by not being able to get the loop to iterate all four values? Do you mean you can't get the loop to run, or something different? You would want to get your four values into some sort of data structure, otherwise you will find the procedure too difficult.

warren brandt

Ranch Hand

Posts: 47

posted 3 weeks ago

hi campbell not allowed to use arrays either

Campbell Ritchie

Marshal

Posts: 62881

203

posted 3 weeks ago

Are you really supposed to write code to test value1, value2, value3, and value4 separately? The idea of the array was so you can see the logic of going through an array looking for the largest element.

See ya later boys, I think I'm in love. Oh wait, she's just a tiny ad: