Tech moves fast! Stay ahead of the curve with Techopedia!
Join nearly 200,000 subscribers who receive actionable tech insights from Techopedia.
In computer science, the state of a program is defined as its condition regarding stored inputs. The term "state" here is used similarly to how it is used in science — whereas the state of an object, for instance, as a gas, liquid or solid, shows its current physical makeup, the state of a computer program shows its current values or contents.
The stored inputs in a computer program are stored as variables or constants. In analyzing the state of a program, developers may go through and look at values that are stored in these inputs. As the program is executed, its state may change — variables can change and the values that are stored in memory can also change. For example, a control variable such as a variable used in a loop changes the state of the program at each iteration. Looking at the state of a program can be considered a testing method or a way of analyzing the code base.
Developers also talk about different types of states, for example, contrasting two complementary states that are not contradictory to one another or contrasting two different states resulting from different operations.