i was wondering if anyone could explain to me how i can find which number is biggest and smallest from an array of numbers.
i dont need any code i just need the basic concept of how to do it, possibly with and algorithm.
please help as i am stuck
i was wondering if anyone could explain to me how i can find which number is biggest and smallest from an array of numbers.
i dont need any code i just need the basic concept of how to do it, possibly with and algorithm.
please help as i am stuck
http://www.cprogramming.com/cboard/s...=&threadid=679
Have alook at the last few posts on this thread, they may help you, or provide some idea's
Demonographic rhinology is not the only possible outcome, but why take the chance
1) store the first number in the array as MAX and MIN
2) loop through the array starting at the second item in the array and finishing at the last item
3) if current loop array item is less than MIN, then store the current value as MIN
4) if current loop array item is more than MAX, then store the current value as MAX
5) loop to end of array and MAX will store the maximum value, and MIN will store the minimum value.
also, you could sort your array and then directly access the first and last items! as always, there are a million ways to skin a cat.
hope that helps.
U.
Quidquid latine dictum sit, altum sonatur.
Whatever is said in Latin sounds profound.