관리 메뉴

Silver Library (Archived)

Iteration vs loop, aren't they the same? 본문

F2. Problem & Solving/Theory of algorithm

Iteration vs loop, aren't they the same?

Ayin Kim 2023. 1. 17. 22:21
반응형

Looks like I made a wrong assumption. Loop and iteration are not the same but sharing some common point. 

What are they?

 

A for loop is a type of loop in programming that allows you to iterate over a sequence of elements, such as a list or an array. It typically includes a loop variable, which is used to keep track of the current element in the sequence, and a loop body, which contains the code that is executed for each element.

 

Iteration, on the other hand, is the process of repeatedly executing a certain block of code. It is a general concept that can be achieved using different types of loops, such as for loops or while loops.

 

In summary,

- for loop is a type of loop that is used to iterate over a sequence of elements

- while iteration is a general concept that refers to repeatedly executing a block of code.