Question #179462

What is the value of x after each of these statements is encountered in a computer program, if x =3 before the statement is reached? 


1
Expert's answer
2021-04-29T16:56:34-0400

i) if x +2=5 then x := 3*x +5

Since 3+2=53+2=5 is a true statement, after the command "if x +2=5 then x := 3*x +5" the value of xx is 33+5=14.3\cdot 3+5 =14.

Answerx=14x = 14


ii) if (x +1=4) OR (2x +2=3) then x := x +1

Since 3+1=43+1=4 is a true statement, the statement (3+1=4) OR (23+2=3)(3 +1=4) \text{ OR }(2\cdot 3 +2=3) is also true, and thus after the command "if (x +1=4) OR (2x +2=3) then x := x +1" the value of xx is 3+1=43+1=4

Answerx=4x = 4

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS