Jump to content

Control variable (programming): Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
m Adjusted hatnote and lead section; added a link to 'For loop'
Redirected page to Control flow
Tag: New redirect
Line 1: Line 1:
#REDIRECT [[Control flow]]
{{short description|Regulates the flow of control of a program}}
{{confuse|text=[[Control variable|Control variables]] in science or [[Controlling for a variable]] in statistics}}

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.<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 ==
In some programming languages, control variables are just ordinary variables used for manipulating the program flow. This is the case of [[C (programming language)|C]], [[Fortran]], and [[Pascal (programming language)|Pascal]], which allow for control variables to have their values changed within the loop body.<ref name="Watt"/> However, some languages have special rules for control variables. In [[Ada (programming language)|Ada]], for instance, the control variable of a [[For loop|for-loop]] must remain constant within the loop body.

== References ==
{{reflist}}

{{Computer science}}

[[Category:Mathematical terminology]]
[[Category:Computing terminology]]



{{comp-sci-stub}}

Revision as of 03:19, 24 February 2023

Redirect to: