Solution to State the value of x after the statement if P(x) then x:=1 is executed, where … - Sikademy
Author Image

Archangel Macsika

State the value of x after the statement if P(x) then x:=1 is executed, where P(x) is the statement “x > 1,” Given that thevalue of x when thisstatement is reachedis [3 marks] a) x=0 b) x=1 c) x =2

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

Consider the statement "if P(x) then x := 1" which is equivalent to "if x>1 then x := 1"


a) If x=0, then the statement P(0)="0>1" is false, and thus the value of x is equal to 0 after the statement "if P(x) then x := 1".


b) If x=1, then the statement P(1)="1>1" is false, and thus the value of x is equal to 1 after the statement "if P(x) then x := 1".


c) If x=2, then the statement P(2)="2>1" is true, and thus the value of x is equal to 1 after the statement "if P(x) then x := 1".

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-3339-qpid-2038