+ 2

Hey guys, who can help me?

How can this code outputs 6. Who can explain? https://code.sololearn.com/WiBxfi5021zW/?ref=app

7th Oct 2017, 6:37 PM
bli$
bli$ - avatar
13 odpowiedzi
+ 1
не знаю как на английском написать, но там обратите же внимание там х с нуля начинается, то есть когда он заходит в цикл первоначальное значение х=0 и когда он видит х=0 он увеличивает значение на 1. то есть при х=0, значение 1, тогда при х=5 значение будет уже 6.
7th Oct 2017, 7:08 PM
Rashid
+ 6
x = 6 and then conditon is false and outputs 6
7th Oct 2017, 6:58 PM
Vukan
Vukan - avatar
+ 3
The last iteration of the while loop increases the value of x from 5 to 6 then the comparison is made x < 6 where x is 6 (6 < 6) this is false so the loop ends and the current value of x (6) is output to the screen.
7th Oct 2017, 6:59 PM
ChaoticDawg
ChaoticDawg - avatar
+ 3
The condition is tested when x = 5, x is then increased by one and then printed.
7th Oct 2017, 7:01 PM
Marcus Raso
Marcus Raso - avatar
+ 1
didnt get it
7th Oct 2017, 7:01 PM
bli$
bli$ - avatar
+ 1
can you explain "по-подробней"))
7th Oct 2017, 7:01 PM
bli$
bli$ - avatar
+ 1
ChaoticDawg, man thank you very much
7th Oct 2017, 7:05 PM
bli$
bli$ - avatar
+ 1
thanks guys
7th Oct 2017, 7:05 PM
bli$
bli$ - avatar
+ 1
hey friend when the condition that is x<6 is used it comes till x=5 that is true for your condition so it will print its increment value 6 and the condition will break from there i think i could hrlp you
7th Oct 2017, 8:14 PM
Aditya Narayan Mishra
Aditya  Narayan Mishra - avatar
+ 1
yes Aditya, you also were a great to help me
7th Oct 2017, 8:16 PM
bli$
bli$ - avatar
+ 1
thnks😊😊😊
7th Oct 2017, 8:17 PM
Aditya Narayan Mishra
Aditya  Narayan Mishra - avatar
0
спасиюо Рашид, за подробный ответ)
7th Oct 2017, 7:35 PM
bli$
bli$ - avatar