• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

do-while loop in real time

 
Harikrishna Gorrepati
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Do we ever use do-while loop in real time applications ? In what scenario, we can use this do-while loop (I am not looking for do-while loop purpose/use/meaning)
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm guessing you mean real-life as opposed to real-time?
If so, then yes, certainly - whenever you need the body of the loop to be executed at least once.

 
Harikrishna Gorrepati
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jelle, Real Time/Real Life applications refers to same context i.e., In the real project. I knew the answer i.e., "you need the body of the loop to be executed at least once. ". As stated in the question, I am not looking for do-while loop purpose/use/meaning. In what scenario(I am looking for some meaningful example/case)(why should we go for this loop only) , we can use this do-while loop. I hope this reply is not rude. If so, Sorry
 
ujjawal rohra
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Harikrishna ,

The answer to your question lies in its use only.
Sometimes in real time applications, we want to execute a piece of code once and on the basis of that execution we decide whether to execute
that code repeatedly or not. For this purpose you cannot use while or for loops; only do-while is suitable.

Hope this will help
 
Harikrishna Gorrepati
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ujjawal. I am happy with your reply that has we want to execute a piece of code once and on the basis of that execution we decide whether to execute
that code repeatedly or no
t
 
ujjawal rohra
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My pleasure HariKrishna and sorry for a late reply
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic