Can I use for loops for things other than arrays?


#1

Question

Can I use for loops for things other than arrays?

Answer

Sure you can, you just need to give it an initial value, a terminating condition, and an iterator. You can customize this however you like, just make sure the initial value can be changed via incrementation/decrementation/etc. via the iterator and will eventually terminate.