Jump to content

Control variable (programming): Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Adding short description: "Regulates the flow of control of a program" (Shortdesc helper)
Bluelink 1 book for verifiability (prndis)) #IABot (v2.0.1) (GreenC bot
Line 3: Line 3:
A '''control variable''' in [[computer programming]] is a [[program variable]] that is used to regulate the [[flow of control]] of the program.
A '''control variable''' in [[computer programming]] 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 of values.<ref name="Watt">{{cite book |last1=Watt |first1=David A. |title=Programming Language Design Concepts |date=2004 |publisher=Wiley |pages=84-85}}</ref>
In definite iteration, control variables are variables which are successively assigned (or bound to) values from a predetermined sequence of values.<ref name="Watt">{{cite book |last1=Watt |first1=David A. |title=Programming Language Design Concepts |url=https://archive.org/details/programminglangu00watt_497 |url-access=limited |date=2004 |publisher=Wiley |pages=[https://archive.org/details/programminglangu00watt_497/page/n102 84]-85}}</ref>


== Special rules ==
== Special rules ==

Revision as of 16:41, 10 June 2020

A control variable in computer programming 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 of values.[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 the 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.