Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 947855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:08:51+00:00 2026-05-15T23:08:51+00:00

Possible Duplicates: While vs. Do While When should I use do-while instead of while

  • 0

Possible Duplicates:
While vs. Do While
When should I use do-while instead of while loops?

I’ve been programming for a while now (2 years work + 4.5 years degree + 1 year pre-college), and I’ve never used a do-while loop short of being forced to in the Introduction to Programming course. I have a growing feeling that I’m doing programming wrong if I never run into something so fundamental.

Could it be that I just haven’t run into the correct circumstances?

What are some examples where it would be necessary to use a do-while instead of a while?

(My schooling was almost all in C/C++ and my work is in C#, so if there is another language where it absolutely makes sense because do-whiles work differently, then these questions don’t really apply.)

To clarify…I know the difference between a while and a do-while. While checks the exit condition and then performs tasks. do-while performs tasks and then checks exit condition.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T23:08:51+00:00Added an answer on May 15, 2026 at 11:08 pm

    If you always want the loop to execute at least once. It’s not common, but I do use it from time to time. One case where you might want to use it is trying to access a resource that could require a retry, e.g.

    do
    {
       try to access resource...
       put up message box with retry option
    
    } while (user says retry);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicates: What’s the use of do while(0) when we define a macro? Why
Possible Duplicate: Should I use Elements or Attributes in XML? I have never been
Possible Duplicates: Iterate with for loop or while loop? Loops in C - for()
Possible Duplicates: Do-While and if-else statements in C/C++ macros do { … } while
Possible Duplicate: Issue while saving image using savefiledialog I use windows forms in C#.
Possible Duplicate: Why avoid while loops? I am trying to learn Python by following
Possible Duplicate: What Java FTP client library should I use? I am looking for
Possible Duplicate: Error handling in C code What return value should you use for
Possible Duplicate: Should I use Elements or Attributes in XML? I'm writing a configuration
Possible Duplicate: What should main() return in C/C++? What does main return? I've been

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.