StatethevalueofxafterthestatementifP(x)thenx:=1
b)x=1.
a)x=0.
isexecuted,whereP(x)isthestatement“x>1,”ifthe
valueofxwhenthisstatementisreachedis
c)x=2.
Let us state the value of "x" after the statement
"``"if "P(x)" then "x:=1"",
where "P(x)=``x>1"," in the following cases:
a) If "x=0," the statemet "P(x)," that is "``0>1"" is false, and hence after the command "``"if "P(x)" then "x:=1"" the value of "x" is equal to 0.
b) If "x=1," the statemet "P(x)," that is "``1>1"" is false, and hence after the command "``"if "P(x)" then "x:=1"" the value of "x" is equal to 1.
c) If "x=2," the statemet "P(x)," that is "``2>1"" is true, and hence after the command "``"if "P(x)" then "x:=1"" the value of "x" is equal to 1.
Comments
Leave a comment