Solved: Find the value of z when each of the algorithm

Chapter 4, Problem 3E

(choose chapter or problem)

Get Unlimited 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

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 ]

Add to cart


Study Tools You Might Need

Not The Solution You Need? Search for Your Answer Here:

×

Login

Login or Sign up for access to all of our study tools and educational content!

Forgot password?
Register Now

×

Register

Sign up for access to all content on our site!

Or login if you already have an account

×

Reset password

If you have an active account we’ll send you an e-mail for password recovery

Or login if you have your password back