what is the difference b/w while(a!=0) and while(a==0) in term of the execution of loop? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

what is the difference b/w while(a!=0) and while(a==0) in term of the execution of loop?

I am confused with these condition that how many time will the loop be executed when we use such condition.

28th Jun 2016, 1:39 PM
Deepak Negi
4 Answers
+ 2
(a!=0) means the loop iterates in all the conditions except when a is 0. If the condition is (a==0) then the loop iterates only when a is equal to 0
28th Jun 2016, 2:01 PM
Sesha Reddy
Sesha Reddy - avatar
+ 1
!= means not equal, == means equal to.....,, the "while" will only execute if the condition is true
28th Jun 2016, 2:27 PM
Gerald Flores
Gerald Flores - avatar
0
while(a==0) doesn't mean that it iterates till a is zero
28th Jun 2016, 2:25 PM
Deepak Negi
0
can you explain it in long
28th Jun 2016, 2:26 PM
Deepak Negi