We use loops to not have a bunch of repetitive lines in the codes. The loops are to better organize the code. The code is repeated in a neater way. There are 3 types of loops. For loop, while loop, and do-while loop. I believe that the for loop is the one, we would use when we run a specific number of times because it has a condition, and when it is reached it displays false and stops. I believe that the while loop is the one, we would use when we don’t know the specific number of times, so it continues to loop until it displays a false. In class, you described the three parts of a for loop as:
for (initial-action; loop-continuation-condition; action-after-each-iteration)
{
// loop body;
Statement(s);
}
Hi Isel,
When mentioning loops, you mentioned that it helps organize and everything stays neat. But forgot to mention that it also saves a bunch of time as well. Your definition of “for loop” helped what it does and how it helps. I like how you showed an example of what a loop would look like. Great Job!