0
How many times is the body of the following loop executed? What are the values of x and y after the loop termination?
int x = 7; int y = 5; while ( x < 11 && y > 3 ) { x++; y−−; }
3 Answers
+ 1
Rao Muzaffar
In the while loop ,
1st ,
Condition:
(x<11 && y>3)=(1&&1)=(true)
x++//so x=7+1=8
y--//so y=5-1=4
Next,
Condition:
(8<11 && 4>3)=(1&&1)=(true)
x++//so, x=9
y--//so, y=3
Next
Condition:
(9<11 && 3>3)=(1&&0)=(false)
So, loop was ended. And x=9 ,y=3.
0
Body of the while executed for 2 times. And the value of x and y after that is : 9 and 3.
0
How can I find it can you guide me a little bit