Sei sulla pagina 1di 4

1.

(a) if 1 + 2 = 3 then x := x + 1

Because 1+2 = 3 is true.

So the assignment statement

X= x+1 is executed.

Hence x has increment.

So the x value will be 1+1=2.

(b) if (1 + 1 = 3) OR (2 + 2 = 3) then x := x + 1

Because 1+1=3 OR 2+2=3 is false

So the assignment statement

X= x+1 is not executed.

Hence x will be 0+1 = 1.

(c) if (2 + 3 = 5) AND (3 + 4 = 7) then x := x + 1

Because 2+3 = 5 AND 3+4 = 7 is true.

So the assignment statement

X= x+1 is executed.

Hence x has increment.

So the x value will be 1+1=2.

(d) if (1 + 1 = 2) XOR (1 + 2 = 3) then x := x + 1

Because 1+1=2 XOR 1+3= 4 is false

So the assignment statement

X= x+1 is not executed.

Hence x will be 0+1 = 1.


(e) if x < 2 then x := x + 1

Condition is true when it is encounter (since x=1)

The statement is executed.

X= x+1 is executed.

Hence x has increment.

So the x value will be 1+1=2 ( it is irreverent that condition


is false.)

2. (a) The statement is P Q

Where P : It rains tonight.

Q : I will Stay at home.

Converse :

Whenever I will stay at home, it rains.

Contra positive :

When I will not stay home , no rain.

Inverse :

It is no rain , I will no stay at home.

(b) We rewrite it as P Q

Where P: It is raining.

Q: The home team wins.

i\If it is raining, then the home team wins.

Converse:

Whenever the home team wins, it is raining.


Contra positive:

If the home does not win, then it is not raining.

Inverse:

If it is not raining, the home team does not win.

4. C(x) is “x is a comedian”

F(x) is “x is funny”

(a) Every comedian is funny.

(b) Every people is comedian and funny.

(c) There exit a people such that it is comedian, then it is funny.

(d) There exit a people which is funny.

Potrebbero piacerti anche