For to While Loop
68 views (last 30 days)
Geoff Hayes on 19 Jun 2014
I'm not sure why a while loop would be better in this case (because it adds a couple of more lines of code) but here is the while equivalent to the above for loop
k = 1;
Note that with this code, we have to manage the initialization of k, the incrementing of k and ensure that the condition has been set correctly.