Jump to content

Control variable (programming)

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by SeparateTitan92 (talk | contribs) at 16:11, 21 April 2022 (Adjusted hatnote and lead section; added a link to 'For loop'). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

In computer programming, a control variable is a program variable that is used to regulate the flow of control of the program.

In definite iteration, control variables are variables which are successively assigned (or bound to) values from a predetermined sequence.[1]

Special rules

In some programming languages, control variables are just ordinary variables used for manipulating the program flow. This is the case of C, Fortran, and Pascal, which allow for control variables to have their values changed within the loop body.[1] However, some languages have special rules for control variables. In Ada, for instance, the control variable of a for-loop must remain constant within the loop body.

References

  1. ^ a b Watt, David A. (2004). Programming Language Design Concepts. Wiley. pp. 84-85.