Please answer and show all work This code prints out the val

Please answer and show all work.

This code prints out the values of x and y a number of times. Figure out what they are. Set x = 3 set y = 1 while x > 1) print \"X line:\", x while (y

Solution

Initial values of:

x = 3

y = 1

Iteration 1 :

x = 3>1 : true

it will print X line : 3

y = 1<=3 : true

it will print Y line : 1

y = y+1

y = 2<=3 : true

it will print Y line : 2

y = 3<=3 : true

it will print Y line : 3

y = 4<=3 : false it ends while loop 1

Decrement x = 3-1 = 2

Iteration 2:

x = 2 > 1 : true

it will print X line : 2

y = 4<=3 : false ends 1st while loop

decrement x = 2-1

iteration 3:

x = 1 > 1 : false

ends while loop 2

Hence final output is :

X line: 3

Y line: 1

Y line: 2

Y line: 3

X line: 2

Please answer and show all work. This code prints out the values of x and y a number of times. Figure out what they are. Set x = 3 set y = 1 while x > 1) pri

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site