Is there any way to have the program search all the arrays and find the largest entry or smallest entry. Also if you have an array of 20 but only assign 15 places and then enter a sentinal of -1 to have the other places filled by zero
Is there any way to have the program search all the arrays and find the largest entry or smallest entry. Also if you have an array of 20 but only assign 15 places and then enter a sentinal of -1 to have the other places filled by zero
You can just do a simple linear search to find the largest / smallest value in an array. Just simply walk through it and compare the current value to the largest / smallest one currently set.
"...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers
And How would one go about doing that. I'm pretty much a novice at c programming.
I'll give you some pseudo code then you make an attempt and coding it and then I can help you again if needed.
That will give you the largest value in your array.Code:integer large = -INT_LIMIT // very small number integer i = 0 for each element in our array data ( for loop.. ) compare current data element with large if data element bigger.. large = data element increment i
"...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers
And How would one go about doing that. I'm pretty much a novice at c programming.
Hah, is there an echo in here?
"...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers
One would do that by reading the first chapter of their C book and going from there. We do not do homework for you here. Do what you can, post your attempt, and read the forum rules.Originally posted by apoc632
And How would one go about doing that. I'm pretty much a novice at c programming.
Quzah.
Hope is the first step on the road to disappointment.
i got it working thanks. By the way the double post was a mistake.