how to loop through an array and jump back to beginning
I'm trying to write a program and part of it is stumping me. I have an array of seven integers. The default value of each is 0. Some have other values though. Here's my issue. When the element is 0, i want to replace the value with x. For example, if array = 0, then x would go into array. So, if array != 0, then i want to put "x" into the next xth element, if that next element is 0. So if x was 3, array!=0 so then it checks array. array =0, so x goes into array. heres my question. it checks array, and it !=0, so i go to the next xth element, which is array in this case. array!=0. now i want to go to the next xth element, but there are no elements, so i want to loop back around to the beginning, starting at array. so the next comparison it would make would be at array. how do i write a loop like this? in order to find the zero, it checks every xth element through the array, looping around until it finds a zero. there is guaranteed to be a zero somewhere.
thanks a bunch.