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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:32:36+00:00 2026-06-11T18:32:36+00:00

Im learning C and saw the first loop listed below in the book im

  • 0

Im learning C and saw the first loop listed below in the book im reading. Im curious whats the difference between the two as I am used to using the second one and cant figure out the difference even though they return different results.

for(i = 0; i < 10; ++i){}

for(i = 0; i <= 10; i++){}
  • 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-11T18:32:38+00:00Added an answer on June 11, 2026 at 6:32 pm

    The first one iterates to 9, the second iterates to 10. That’s all.

    The pre-/post- increment operation makes no difference.

    Un-optimized code generated for both versions:

        for(int i = 0; i < 10; ++i)
    00E517AE  mov         dword ptr [i],0  
    00E517B5  jmp         wmain+30h (0E517C0h)  
    00E517B7  mov         eax,dword ptr [i]  
    00E517BA  add         eax,1  
    00E517BD  mov         dword ptr [i],eax  
    00E517C0  cmp         dword ptr [i],0Ah  
    00E517C4  jge         wmain+53h (0E517E3h)  
        {
        }
    
        for(int i = 0; i <= 10; i++)
    00E517E3  mov         dword ptr [i],0  
    00E517EA  jmp         wmain+65h (0E517F5h)  
    00E517EC  mov         eax,dword ptr [i]  
    00E517EF  add         eax,1  
    00E517F2  mov         dword ptr [i],eax  
    00E517F5  cmp         dword ptr [i],0Ah  
    00E517F9  jg          wmain+88h (0E51818h)  
        {
        }
    

    So, even here, there is no performance penalty. The fact that i++ is slower than ++i is just not true (at least in this context, where it doesn’t make a difference). It would be slower for, say int y = i++, but in this case, the two would do different things, which is not the case here. The performance issue might have been valid on compilers from 20 years ago, but not anymore.

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

Sidebar

Related Questions

I'm currently learning Java, using a combination of the Head First Java book and
I'm learning C and I saw in a book that a function prototype has
I'm learning about web services, and saw various examples. Some of them used @WebService
I am learning Haskell and reading the book, Learn You a Haskell for Great
Learning xml, Can anyone help me? I have following XML code: **<book lang=en>name of
When I was learning .NET I saw it as a platform that runs my
Still in the early stages of learning Java and I saw the following in
I'm learning WPF, so I'm kind of n00b in this. I saw some examples
When learning regular expressions, I once saw the following four examples. How can I
I started learning JavaScript last week, I saw this code yesterday and I did

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.