Loop

Why Trust Techopedia

What Does Loop Mean?

A loop is a programming function that iterates a statement or condition based on specified boundaries.

Advertisements

The loop function uses almost identical logic and syntax in all programming languages. Thus, a specific statement or a group of instructions is continuously executed until a specific loop body or boundary condition is reached. The result of the entire loop body’s first operation cycle serves as the next repetition’s starting point.

Techopedia Explains Loop

A loop repeatedly executes code in its body until the loop conditional statement becomes false.

A loop is divided into two parts:

  • Loop Statement: This defines the time limit to be true for the continuous loop that is contingent on the attached conditional statement.
  • Loop Body: This holds the statement’s code or instruction; it is is executed with each loop cycle.

Here is an example of a loop (a for loop) in C#:

int i; 
string numbers = ""; 
for (i = 1; i <= 9; i++) 
 numbers += i.ToString(); 
Console.WriteLine(numbers);

The output of the example is: “123456789.”

Advertisements

Related Terms

Margaret Rouse
Technology Expert
Margaret Rouse
Technology Expert

Margaret é uma premiada redatora e professora conhecida por sua habilidade de explicar assuntos técnicos complexos para um público empresarial não técnico. Nos últimos vinte anos, suas definições de TI foram publicadas pela Que em uma enciclopédia de termos tecnológicos e citadas em artigos do New York Times, Time Magazine, USA Today, ZDNet, PC Magazine e Discovery Magazine. Ela ingressou na Techopedia em 2011. A ideia de Margaret de um dia divertido é ajudar os profissionais de TI e de negócios a aprenderem a falar os idiomas altamente especializados uns dos outros.