State the value of x after the statement if P(x) then x := 1 is executed, where P(x) is the statement “x > 1,” if the value of x when this statement is reached is
x = 0.
x = 1.
x = 2.
this answer :
F , x=0
F, x=1
T, x=1
I don't understand the question and answer , can you explain it ?
I assume that we are working with a pseudo-programmming language and that we are asked to evaluate what happens with the "conditional instruction" :
When :
$x=0$, we have that $0 > 1$ is false; thus the operation of assigning $1$ to $x$ is not performed and $x$ has the value $0$
$x=1$, we have that $1 > 1$ is false; thus the operation of assigning $1$ to $x$ is not performed and $x$ has the value $1$
$x=2$, we have that $2 > 1$ is true; now the operation of assigning $1$ to $x$ is performed and $x$ change its value to $1$.