How do I modify array elements while in the for loop?

I have a for loop that traverses an array and finds the max and then sets that element to zero, but that does not work since the for loop is going through the array. Is there a way to solve this?
Each time you find a new max, save its index. By the time you get out of the loop, you will have the index of the maximum element saved.

Outside the loop, simply assign 0 to the element at that index.
But if I exit the loop in order to assign 0, then how do I go back into the loop?
Last edited on
Topic archived. No new replies allowed.