for loop

for loop

(programming)
A loop construct found in many procedural languages which repeatedly executes some instructions while a condition is true.

In C, the for loop is written in the form;

for (INITIALISATION; CONDITION; AFTER) STATEMENT;

where INITIALISATION is an expression that is evaluated once before the loop, CONDITION is evaluated before each iteration and the loop exits if it is false, AFTER is evaluated after each iteration, and STATEMENT is any statement including a compound statement within braces ".." that is executed if CONDITION is true.

For example:

int i; for (i = 0; i < 10; i++) printf

prints "Hello" 10 times.

The for loop is an alternative way of writing a while loop that is convenient because the loop control logic is collected in a single place. It is also closely related to the repeat loop.
This article is provided by FOLDOC - Free Online Dictionary of Computing (foldoc.org)

for statement

A high-level programming language structure that repeats a series of instructions a specified number of times. It creates a loop that includes its own control information. The following BASIC and C examples print "Hello" 10 times:

BASIC             C

 for x=1 to 10     for (x=0; x<10; x++)
  print "hello"     printf ("hello\n");
 next x
Copyright © 1981-2025 by The Computer Language Company Inc. All Rights reserved. THIS DEFINITION IS FOR PERSONAL USE ONLY. All other reproduction is strictly prohibited without permission from the publisher.
Mentioned in
Copyright © 2003-2025 Farlex, Inc Disclaimer
All content on this website, including dictionary, thesaurus, literature, geography, and other reference data is for informational purposes only. This information should not be considered complete, up to date, and is not intended to be used in place of a visit, consultation, or advice of a legal, medical, or any other professional.