📖 Samacheer Kalvi · 11th TN - English Medium · Computer Science · Page 82question

Solving · Part 3

Chapter 2: Chapter 2 · Computer Science

. . Variables Variables are named boxes for storing data. When we do operations on data, we need to store the results in variables.

The data stored in a variable is also known as the value of the variable. We can store a value in a variable or change the value of variable, using an assignment statement. Computational processes in the real-world have state. As a process evolves, the state changes.

How do we represent the state of a process and the change of state, in an algorithm? The state of a process can be represented by a set of variables in an algorithm. The state at any point of execution is simply the values of the variables at that point. As the values of the variables are changed, the state changes.

Example . . State: A traffic signal may be in one of the three states: green, amber, or red. The state is changed to allow a smooth flow of traffic.

The state may be represented by a single variable signal which can have one of the three values: green, amber, or red. . . Control flow An algorithm is a sequence of statements.

However, after executing a statement, the next statement to be executed need not be the next statement in the algorithm. The statement to be executed next may depend on the state of the process. Thus, the order in which the statements are executed may differ from the order in which they are written in the algorithm. This order of execution of statements is known as the control flow.

There are three important control flow statements to alter the control flow depending on the state. • In sequential control flow, a sequence of statements are executed one after another in the same order as they are written. • In alternative control flow, a condition of the state is tested, and if the condition is true, one statement is executed; if the condition is false, an alternative statement is executed. • In iterative control flow, a condition of the state is tested, and if the condition is true, a statement

Related topics

Have a question about this topic?

Get an AI answer grounded in your actual textbook — with the exact page reference.

Ask AI about this topic →