using the current values of the variables, and then store them in the corresponding variables on the left side. Example . . What are the values of variables m and n after the assignments in line ( ) and line ( )?
The assignment in line ( ) stores in variable m, and in variable n. m n The assignment in line ( ) evaluates the expressions m + and n - using the current values of m and n as m + , n - = + , - = , and stores the values and in the variables m and n, respectively. m n . m, n := , .
-- m, n = , . m, n := m + , n - . -- m, n = + , - = , Values of the variables after the two assignments are shown in in line ( ) and line( ). Example .
. In Example . , we abstracted the state of the process by two Chapter Page - - variables p and c. The next step is to model the process of cutting the chocolate bar.
When we make a single cut of a piece, the number of pieces (p) and the number of cuts (c) both increase by . We can model it by an assignment statement. p, c := p + , c+ Points to Remember: which is read as p and c "become" p + and c + , respectively. • A programming language provides basic statements and a notation for composing compound statements.
• An algorithm is a step-by-step sequence of statements to solve a problem. • As an algorithm is executed, a process evolves which solves the problem. • Algorithmic problem solving involves construction of algorithms as well as proving properties of algorithms. • The specification of an algorithm consists of the name of