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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:43:19+00:00 2026-06-13T14:43:19+00:00

while(cond) // fine for(;cond;) //fine but when I remove the conditional part while() //syntax

  • 0
while(cond) // fine
for(;cond;) //fine

but when I remove the conditional part

while() //syntax compilation error 
for(;;) //Infinite loop

How these loops are internally implemented ?
Or,how does compiler (parser) know that empty condition in while is error and in for as Infinite?

I didn’t find anything about this particularly, I think guys like me (who are beginner) in C might have same confusion

  • 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-13T14:43:21+00:00Added an answer on June 13, 2026 at 2:43 pm

    The standard requires that the omitted condition for for loop is replaced by a non-zero constant:

    From C11 6.8.5.3: (emphasis mine)

    6.8.5.3 The for statement

    1 The statement for ( clause-1 ; expression-2 ; expression-3 )
    statement behaves as follows: The expression expression-2 is the
    controlling expression that is evaluated before each execution of the
    loop body. The expression expression-3 is evaluated as a void
    expression after each execution of the loop body. If clause-1 is a
    declaration, the scope of any variables it declares is the remainder
    of the declaration and the entire loop, including the other two
    expressions; it is reached in the order of execution before the first
    evaluation of the controlling expression. If clause-1 is an
    expression, it is evaluated as a void expression before the first
    evaluation of the controlling expression.134)

    2 Both clause-1 and expression-3 can be omitted. An omitted expression-2 is replaced by a nonzero constant.

    Since there’s no such requirement for while loop (if the condition is omitted), I believe, it’s left to the implementation of compiler.

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

Sidebar

Related Questions

Ruby, which is normally very forgiving, is giving me an error on a while
I have a code like, String str = ; while( cond ) { str
Taken from Programming ruby 1.9 book: def my_while(cond, &body) while cond.call body.call end end
boost::condition_variable cond; boost::mutex mutex; //thread #1 for(;;) { D * d = nullptr; while(
boost::condition_variable cond; boost::mutex mut; bool ready = false; void consumer() { boost::mutex::scoped_lock lock(mut); while
I have the following consumer code: .... while 1: time.sleep(self.sleeptime) cond.acquire() #acquire the lock
I'm having a problem with mod_rewrite on my hosting. All is working fine, but
While debugging and keep pressing F5, if the source code does not exist, eclipse
While trying to build the mysql2 gem with ruby 1.9.2-p320 on Fedora 16, I
While deveoping a site (using Forms authentication and InProc sessionstate) a frequently run into

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.