23 AnswersNew Answer
I hate do while loop *Exit controlled loop *Post tested *Runs atleast once even if it's condition is true or false *writing the body inside statment without knowing the condition first. and making the condition at the end Every thing has own advantage and disadvantage But in most cases do while not so powerful, some may say it's not a standard way to code using do while . I prefer for and while loop Even while loop also have some disadvantages . But comparing while and do while While is more better than do while
https://code.sololearn.com/cVbstyuLlINs In the above code why the count value 8 is not going to print ?
It depends on the code you're writing. Do while loop runs the code at least once before testing it, and while loop tests it and then runs it
If you know that much then it's totally need based, there is no question of which is better !
Change to count<=8. Loop exiting when count =8, hence will not repeat.
They both perform different task so we can't say which one is better
Both of them have their importance. Which one is good at which logic It's all depend Because some time we want our code run at least once before checking a condition so we prefer to use do- while In some case we want to check 1st condition then we opt while loop
Once the count becomes 8, the next statement executed is condition check, since the condution will become false, the loop exist immidiately.
While loop because Python does not have do while loop.
Do while is best but for long program For short problem while lope is best💻🖥️
It depends on what you want to use it for. A while loop won't run if the condition is false, but a do-while loop will run at least once before it is terminated.
I prefer While loop as it checks the condition first and then goes into the loop.
It depends on the program If it is necessary to run the instructions at least one time in the given program ,then we must use do while Otherwise while is enough But,we can't say which is better for use it depends on the program .
You need to count=8 Or count<9
As do while is prefer when you want to run the program at least once .but while much easygoing
while is semple
while is an entry controlled loop, *while* do-while is an exit controlled loop structure.
Do you get to Know difference between do while and while
for is usually used for a countable number of iterations while and do..while loops are used when we have conditional execution. Do..while just makes sure you do something atleast once. Eg. Printing a menu While makes sure you do something only after checking But rather than this its depends on the condition you are giving because the do while is exit control loop its check the condition at the end of the loop and the while is entry control that's check the condition at the starting of the loop...
which is better a hammer or a saw? just use the right tool for the right job.