5 Answered Questions for the topic loops
C++ Factorial Problem using Vectors
I am new to C++ and am struggling with a recent practice problem, I have some code so far but can't figure out how to get the variable to update to correctly give the next factorial. Here is the... more
In Ruby, how do I skip a loop in a .each loop, similar to 'continue'?
In Ruby, how do I skip a loop in a `.each` loop, similar to `continue` in other languages?
How to perform an action every 5 results?
How can I perform an action within a `for` loop every 5 results? Basically I'm just trying to emulate a table with 5 columns.
Accessing the index in 'for' loops?
How do I access the index itself for a list like the following? ints = [8, 23, 45, 12, 78]When I loop through it using a `for` loop, how do I access the loop index, from 1 to 5 in this case?
What is the "right" way to iterate through an array in Ruby?
PHP, for all its warts, is pretty good on this count. There's no difference between an array and a hash (maybe I'm naive, but this seems obviously right to me), and to iterate through either you... more