00:02
Do the following statements below.
00:04
Add 1 to x.
00:06
If x is positive then subtract 1 from x.
00:08
If x is negative then leave x alone.
00:09
If x is 0.
00:11
Looking at the options that would be option b.
00:14
Because we have if x is greater than 0 then increment x, add 1 to x.
00:20
Else if x is less than 0 decrement x and leave x alone if x is 0.
00:28
Because that's what's left.
00:29
There is no other else statement.
00:33
So it just doesn't do anything if x is 0.
00:36
So that's going to be option.
00:39
Question 3 will be option b.
00:43
And then question 4.
00:47
We have the nested if else structure.
00:51
If x is currently 0, a is equal to 5 and b is equal to 5.
00:56
What will be x after the above statement is executed.
01:03
So the first part we have if a is greater than 0.
01:11
So that is true.
01:13
And then we have if b is less than 0 that's false.
01:17
So it goes to the else.
01:19
If a is greater than 5 that is false.
01:22
So it goes to the else.
01:24
So we have x is equal to x plus 3.
01:27
So we're going to have x is equal to 0 plus 3 which is equal to 3.
01:35
Question 5.
01:39
If x is currently 0, a is equal to 0 and b is equal to minus 5.
01:43
What will be x after the above statement is executed.
01:48
So the first line is going to be false.
01:53
So it goes straight to else.
01:57
X is equal to x plus 2...