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−−; }

24th Jun 2021, 2:46 AM
Rao Muzaffar
Rao Muzaffar - avatar
3 Respuestas
+ 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.
24th Jun 2021, 3:06 AM
˜”*°•.˜”*°• Mohan 333 •°*”˜.•°*”˜
˜”*°•.˜”*°• Mohan 333 •°*”˜.•°*”˜ - avatar
0
Body of the while executed for 2 times. And the value of x and y after that is : 9 and 3.
24th Jun 2021, 2:56 AM
˜”*°•.˜”*°• Mohan 333 •°*”˜.•°*”˜
˜”*°•.˜”*°• Mohan 333 •°*”˜.•°*”˜ - avatar
0
How can I find it can you guide me a little bit
24th Jun 2021, 2:57 AM
Rao Muzaffar
Rao Muzaffar - avatar