Solution to (b) What is the value of x after each of these statements is encountered in … - Sikademy
Author Image

Archangel Macsika

(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) OR (x +2=5) then x = x +1

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

Answer to Question #179461 in Discrete Mathematics for Rishail

Question #179461

(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) OR (x +2=5) then x = x +1 



Expert's answer

(i)

3+2=5 is true, so x=3*3+5=14

Answer: x=14


(ii)

3+1=4 is true, so (3+1=4 or 6+2-3) is true, so x=3+1=4

Answer: x=4


(iii)

2*3+3=5 if false, so (2*3+3=5 and 3*3+4=13) is false, so x=3 as at the beginning of the program

Answer: x=3


(iv)

3+1=4 is true, 3+2=5 is true, so (3+1=4 or 3+2=5) is true, so x=3+1=4

Answer: x=4


Related Answers

Was this answer helpful?

Join our Community to stay in the know

Get updates for similar and other helpful Answers

Question ID: mtid-5-stid-8-sqid-3196-qpid-1895