Using more { } to denote exactly which bits of code belong to which block would certainly help clarify the problem.
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
very simple: you are using ' i ' in two nested loops and every time you enter a loop i becomes 0 (lines 14 and 25)
Nick Evan
Not a Llama
10,112 posts since Oct 2006
Reputation Points: 4,142
Solved Threads: 403
I have no idea what your program is supposed to do, so maybe you could clear this up?
Nick Evan
Not a Llama
10,112 posts since Oct 2006
Reputation Points: 4,142
Solved Threads: 403
Hmm, sounds a bit strange to me. How about using a simple bubblesort on the original array? That way arr[0] would be smallest and arr[4] will be biggest. No need for an extra array right?
Nick Evan
Not a Llama
10,112 posts since Oct 2006
Reputation Points: 4,142
Solved Threads: 403