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
The Answer to the Question
is below this banner.
Can't find a solution anywhere?
NEED A FAST ANSWER TO ANY QUESTION OR ASSIGNMENT?
Get the Answers Now!You will get a detailed answer to your question or assignment in the shortest time possible.
Here's the Solution to this Question
Let
i) Since is a true statement, after the command "if x +2=5 then x := 3*x +5" the value of is
Answer:
ii) Since is a true statement, the statemant is also true, and thus after the command "if (x +1=4) OR (2x +2=3) then x := x +1" the value of is
Answer:
iii) Since is a false statement, the statement "( ) AND ( )" is also false, and thus after the command "if (2x +3=5) AND (3x +4=13) then " the value of does not change.
Answer:
iv) Since is a true statement and is a true statement, the statement
"( ) XOR ( )" is false, and thus after the command "if (x +1=4) XOR (x +2=5) then x := x +1" the value of does not change.
Answer:
v) Since is a false statement, after the command "if then " the value of does not change.
Answer: