0

How can I understand more harder while loop??

for example take this c++ code:- int x=0; while(0){ if(x<3){ x++; } cout << (x=='1')

28th Mar 2018, 3:31 PM
Yogesh Yadav
Yogesh Yadav - avatar
5 Respostas
+ 1
You can shorten that and make it execute by... while (x < 3) { x++; cout << (x == 1); } Also what do you not understand about while loops?
28th Mar 2018, 3:41 PM
TurtleShell
TurtleShell - avatar
+ 2
the while loop in this example is not going to be run even one time this while loop's condition is 0 which means false. while(0) is equal to while(false) when condition is false the loop do not run...... here loop will not run and it will go to cout<<(x == '1') which will print 0 because it is false that x=='1'
28th Mar 2018, 3:43 PM
Raj Chhatrala
Raj Chhatrala - avatar
+ 2
thanks Alex for supporting me. and i don't care if anyone downvote me. 😂😎
28th Mar 2018, 4:16 PM
Raj Chhatrala
Raj Chhatrala - avatar
+ 1
Whoever downvoted @Raj Chhatrala: He is right. The code in the body of a while(false) loop won't get executed.
28th Mar 2018, 4:05 PM
Alex
Alex - avatar
0
I think he wanted to write while(!x)
28th Mar 2018, 4:16 PM
Doodz
Doodz - avatar