Hamed - if your for loop is something like
then you can replace it with a while loop and allow the looping to continue from the first iteration whenever your condition is true
k = 1;
while k<=n
if condition is true
k = 1;
else
k = k + 1;
end
end
The only trick is making sure that you don't get stuck in this loop. When would the condition be false for all iterations that would finally cause the code to exit the loop?
Best Answer