Answer to Question #147066 in Discrete Mathematics for taha

Question #147066
b) 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?
i) if x +2=5 then x := 3*x +5
ii) if (x +1=4) OR (2x +2=3) then x := x +1
iii) if (2x +3=5) AND (3x +4=13) then x := x^2 +x+7
iv) if (x +1=4) XOR (x +2=5) then x := x +1
v) if x<2 then x := 4*x^3
1
Expert's answer
2020-11-27T17:16:11-0500

Let "x:=3."


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

Answer: "x = 14"


ii) Since "3+1=4" is a true statement, the statemant "(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 "x" is "3+1=4"

Answer: "x = 4"


iii) Since "2\\cdot 3+3=5" is a false statement, the statement "("2\\cdot 3 +3=5" ) AND ("3\\cdot 3 +4=13" )" is also false, and thus after the command "if (2x +3=5) AND (3x +4=13) then "x := x^2 +x+7" " the value of "x" does not change.

Answer: "x = 3"


iv) Since "3+1=4" is a true statement and "3+2=5" is a true statement, the statement

"("3 +1=4" ) XOR ("3 +2=5" )" is false, and thus after the command "if (x +1=4) XOR (x +2=5) then x := x +1" the value of "x" does not change.

Answer: "x = 3"


v) Since "3<2" is a false statement, after the command "if "x<2" then "x := 4\\cdot x^3" " the value of "x" does not change.

Answer: "x = 3"



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!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS