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 889633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:35:56+00:00 2026-05-15T13:35:56+00:00

This is a small piece of code shown below which is using do while

  • 0

This is a small piece of code shown below which is using do while loops.
I really dont understand the unexpected behaviour i see when i execute this code.This code shown below uses a do while loop condition and from my knowledge a do while loops executes in such a way that if first executes the statement and then checks in the while part if the condition is true or not.But when i execute this code it never comes out of the loop and goes on forever.Can anyone please tell me why is it happening?

           unsigned int A = 5;
           int B = 0;
           main()
          {
               do
               {
                   A = A + 5;
                   B = B - 1;
               }while(B > A);

           printf("hello\n");
          }

Now i never get the “hello” printed.

Thanks in advance
Maddy

  • 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-15T13:35:57+00:00Added an answer on May 15, 2026 at 1:35 pm

    prints “hello” for me. takes a while (well, a second or two).

    modified to this…

    void main()
    {
        unsigned int A = 5;
        unsigned int loop = 0;
        int B = 0;
        do
        {
            A = A + 5;
            B = B - 1;
            loop++; 
        }while(B > A);
    
        printf("hello %d  %d %d\n", B, A, loop);
    }
    

    prints out :-

    hello -715827882  -715827881 715827882
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So i have this small piece of code which just wont work: while c<b:
I have this small piece of code that basically takes a list and runs
Hey, I'm really struggling with this one. I'am trying to port a small piece
I have this small piece of code. private void Application_Startup(object sender, StartupEventArgs e) {
I have this small piece of code String[] words = {{apf,hum_,dkoe,12f}; for(String s:words) {
I have build.xml for my project, but even this small piece of code <target
Below is a small piece of code that copies 4 elements from an array
I have this small piece of code and i want to to simulate the
I encountered this small piece of code in this question , & wanted to
Can somebody explain me why the small piece of code doesn't work? This is

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.