Solution Found!
Solved: Find the value of z when each of the algorithm
Chapter 4, Problem 3E(choose chapter or problem)
Consider the following algorithm segment:
if \(x \cdot y\) > 0 then do \(\begin{array}{l}
y:=3 \cdot x \\
x:=x+1 \text { end do }
\end{array}\)
\(z:=x \cdot y\)
Find the value of z if prior to execution x and y have the values given below.
a. x = 2, y =3
b. x = 1, y = 1
Text Transcription:
x cdot y
y := 3 cdot x
x := x + 1 end do
z := x cdot y
Questions & Answers
QUESTION:
Consider the following algorithm segment:
if \(x \cdot y\) > 0 then do \(\begin{array}{l}
y:=3 \cdot x \\
x:=x+1 \text { end do }
\end{array}\)
\(z:=x \cdot y\)
Find the value of z if prior to execution x and y have the values given below.
a. x = 2, y =3
b. x = 1, y = 1
Text Transcription:
x cdot y
y := 3 cdot x
x := x + 1 end do
z := x cdot y
ANSWER:Solution a. x = 2, y =3 [suppose x = 2 and y = 3 as per our initial assumption] Step 1 : if x · y > 0 [ satisfy the condition ]