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

  • Home
  • SEARCH
  • 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 8455025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:10:48+00:00 2026-06-10T12:10:48+00:00

This chunk of code is in a exercise from the book named C programming-A

  • 0

This chunk of code is in a exercise from the book named C programming-A Modern Approach.

for(i=10;i>=1;i/=2)
{
    printf("%d", i++);
}

Edited:

The first output should be 10 and it should increase by 1 for the next step in the loop.But when i run this code all i get is 1 and it never ceases to print 1.

Please help me understand this code.

  • 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-06-10T12:10:49+00:00Added an answer on June 10, 2026 at 12:10 pm

    This code says

    for( start with 10 ; as long as it is greater or equals 1 ; divide i by 2){
        Print i;
        add 1 to i
    }
    

    So:

    start with 10:
    print 10;
    10 + 1 = 11
    11 / 2 = 5,5 = 5 because it's int
    print 5
    5 + 1 = 6
    6 / 2 = 3
    print 3
    3 + 1 = 4
    4 / 2 = 2
    print 2
    2 + 1 = 3
    3 / 2 = 1
    print 1
    1 + 1 = 2
    2 / 2 = 1
    print 1
    1 + 1 = 2
    2 / 2 = 1
    .... and it will continue forever and ever
    

    Execution order of for loops:

    for([init];[1];[3]){
        [2]
    }
    

    Of course the order [1],[2],[3] is repeated until [1] is not true anymore

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a chunk of javascript code from a tutorial where they are trying
In the def(pentagon): chunk I've named a variable first . However, this causes an
Cheers, I ran into this chunk of code in Programming Game AI by Example:
I ran across this chunk of code (modified) in our application, and am confused
can anyone offer a selector to do away with this horrible chunk of code:
This morning we found an old chunk of code that was causing a library
If I have a chunk of code like this: .hover( function () { hoverState($(#navbar
I have this chunk of javascript that's kind of hacked around from http://www.developphp.com/view.php?tid=1248 and
How can I improve performance of this chunk of code ? What would be
Can someone verify the integrity of this chunk of code? I want to decorate

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.