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 printf(“Hello\n”);
prints “Hello” 10 times.
Other languages provide a more succinct form of “for” statement specifically for iterating over arrays or lists. E.g., the Perl code,
for my $task (@tasks) postpone($task);
calls function “postpone()” repeatedly, setting $task to each element of the “@tasks” array in turn. This avoids introducing temporary index variables like “i” in the previous example.
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.
(2009-10-07)

Tagged:

Read Also:

  • Forlorn

    [fawr-lawrn] /fɔrˈlɔrn/ adjective 1. desolate or dreary; unhappy or miserable, as in feeling, condition, or appearance. 2. lonely and sad; forsaken. 3. expressive of hopelessness; despairing: forlorn glances. 4. bereft; destitute: forlorn of comfort. /fəˈlɔːn/ adjective 1. miserable, wretched, or cheerless; desolate 2. deserted; forsaken 3. (postpositive) foll by of. destitute; bereft: forlorn of hope […]

  • Forlorn-hope

    noun 1. a perilous or desperate enterprise. 2. a vain hope. 3. Obsolete. a group of soldiers assigned to perform some unusually dangerous service. noun 1. a hopeless or desperate enterprise 2. a faint hope 3. (obsolete) a group of soldiers assigned to an extremely dangerous duty



  • Forlornly

    [fawr-lawrn] /fɔrˈlɔrn/ adjective 1. desolate or dreary; unhappy or miserable, as in feeling, condition, or appearance. 2. lonely and sad; forsaken. 3. expressive of hopelessness; despairing: forlorn glances. 4. bereft; destitute: forlorn of comfort. /fəˈlɔːn/ adjective 1. miserable, wretched, or cheerless; desolate 2. deserted; forsaken 3. (postpositive) foll by of. destitute; bereft: forlorn of hope […]

  • Forlornness

    [fawr-lawrn] /fɔrˈlɔrn/ adjective 1. desolate or dreary; unhappy or miserable, as in feeling, condition, or appearance. 2. lonely and sad; forsaken. 3. expressive of hopelessness; despairing: forlorn glances. 4. bereft; destitute: forlorn of comfort. /fəˈlɔːn/ adjective 1. miserable, wretched, or cheerless; desolate 2. deserted; forsaken 3. (postpositive) foll by of. destitute; bereft: forlorn of hope […]



Disclaimer: For loop definition / meaning 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. All content on this website is for informational purposes only.