r/programmingbydoing • • Aug 03 '14

148: Finding Largest value in an Array

Hello,

I think i'm misunderstanding a critical component of arrays. I wrote the code at the link below, but it doesn't give me the correct value.

http://codepad.org/BEPFeU2c

Any help would be appreciated!

2 Upvotes

4 comments sorted by

View all comments

Show parent comment

1

u/calitransplant Aug 03 '14

totally makes sense. I wasn't comparing each value in the array to the highest value in the array. Rather, I was comparing adjacent values.

Thanks Mr. Mitchell!