Plz tell me the advantages of using "while" and "do-while" loop in C++

Recommended Answers

All 8 Replies

Please provide a context as your question is otherwise impossible to answer adequately.

they let you run the program over and over again.
a while loop is a loop where if the condition is met it will keep doing what inside the loop over and over again.
a do while loop does whats inside then if a condition is met it does it again and again.

this is good for if you wanna set up something like run this program again? or if you want the program to do something over and over for a certain condition

>they let you run the program over and over again.
Interesting interpretation.

>a while loop is a loop where if the condition is met it will
>keep doing what inside the loop over and over again.
>a do while loop does whats inside then if a
>condition is met it does it again and again.
What a fantastic way to confuse people.

>they let you run the program over and over again.
Interesting interpretation.

>a while loop is a loop where if the condition is met it will
>keep doing what inside the loop over and over again.
>a do while loop does whats inside then if a
>condition is met it does it again and again.
What a fantastic way to confuse people.

wanna tell me which part is gonna confuse people so i can better explain it? or could i just be confusing you o.0

i have seen you post around. i wont waste my time with you. if danishamman comes back and has a problem with what i said. i'll retype so that he understands it better

wanna tell me which part is gonna confuse people so i can better explain it? or could i just be confusing you o.0

i have seen you post around. i wont waste my time with you. if danishamman comes back and has a problem with what i said. i'll retype so that he understands it better

i think u've given a very lucid explanation of while and do while loop... the difference instantly registered in ma mind.. thanks

'Advantages'? It depends on what you mean with it ...

They're both used to repeat a chunk of code as long as a condition is true, but using do-while, your code is executed one time at least ...

I am surprised that the OP is not even participating in the discussion!
Anyway, if the OP bothers to see this thread, here is somewhat explanation from my side:
There are three loops in C,C++ namely while, do-while and for. Let this be clear in your mind that each loop, can be (theoretically) used instead of the other. So, why invent three loops in the first place? The answer may lie in 'comfort'. That is, each loop designed to help you in different situations. No loop is 'superior' than other.
So, in short, there are ADVANTAGES of each loop in its own domain.
The applications of each loop is too trivial and hence I am omitting it here.
Hope this helps!

>wanna tell me which part is gonna confuse people so i can better explain it?
Let's see...maybe...possibly, the part where you answered a completely different question from the one that was asked. The OP asked what the advantages of the two loops are (with advantages in all caps, I might add, so not really easy to miss).

>or could i just be confusing you o.0
You're welcome to try. Usually people around here only manage to confuse me with incredible stupidities.

>i have seen you post around. i wont waste my time with you.
What a shame. I'm sure it would be quite entertaining if you went on a quest to bring me down. People who do that are always good for a few weeks of amusement.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.