Computer Science, asked by kylecabato28, 5 months ago

10. If originally x = 0, y = 0, and z = 1, what is the value ofx, y, andz after executing the following code?
if(x) ther
x=1
y=X+2
Else X+=1
End If
Answer:
11. If originally x = 0, y = 0, and z = 1, what is the value of x, y, and z after executing the fol owing code?
If(x) then
y=x+2
Else: X-*=1
End
Answer:​

Answers

Answered by varshamittal029
0

Concept:

In the if statement, the program examines the test expression and only executes the statement(s) if the test expression returns True. The statement(s) are not executed if the test expression is False.

Given:

x=0\\y=0\\z=1

Find:

Find the values of x, y, and z after executing the program.

Solution:

10) x=0,y=0,z=1 (given)

The first statement if(x) will return False as x=0.

Therefore, 'else' part will get executed.

x+=1\\x=x+1\\x=0+1\\x=1

Answer: x=1, y=0,z=1

11) Now updated values are x=1, y=0,z=1

The first statement if(x) will return True as x=1.

Therefore, 'if then' part will get executed.

y=x+2\\y=1+2\\y=3

Answer: x=1, y=3,z=1

Similar questions