I need to write a segment of a code where it allows the program to run in a loop basically...so the range of this code is going to be from 0 - (N-1) for example, I want:
if the code happens to produce -1, I want it to go to N-1 thus creating a loop. Similarly
if the code happens to produce N, I want it to go to 0, again, going back to the beginning to connect the entire sequence...
starting at 0:
dis is the output.Code:if(u < a / 3) { dis--; } else if(u >= 2 * a / 3) { dis++; }
EDIT: I realize that else if statements must end with an else statement, but if the value turns out to be between a/3 and 2a/3, nothing happens, so should I just add:
Code:else { dis = dis; }
so what do I need to add at the end of that if-loop to ensure I won't get any values less than zero and greater than N-1?