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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:55:53+00:00 2026-06-09T03:55:53+00:00

Possible Duplicate: Why use a for loop instead of a while loop? I am

  • 0

Possible Duplicate:
Why use a for loop instead of a while loop?

I am currently using embedded c. Software that i am using is keil uvision.

So i have a question regarding on which loop will u use?
Both loop does the exact same thing. As long as signal = 0, ‘i’ will increase by 1.

Firstly,

for(;signal==0;)
{
    i++;
}

The next program:

while(signal==0)
{
    i++;
}

So which loop would you use and Why? What is the difference between both of them?
Does it have any difference in terms of time taken to execute? Or it is purely based on your preference?

  • 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-09T03:55:54+00:00Added an answer on June 9, 2026 at 3:55 am

    Generally speaking, for loops are preferred when the number of iterations is known (i.e. for each element in an array), and while loops are better for more general conditions when you don’t know how many times you’ll run the loop. However, a for loop can do anything a while loop can, and vice versa; it all depends on which one makes your code more readable

    In this case, a while loop would be preferable, since you’re waiting for signal == 0 to become false, and you don’t know when that will occur.

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

Sidebar

Related Questions

Possible Duplicate: Using bind1st for a method that takes argument by reference I have
Possible Duplicate: How to Use setTimeout in a for…loop calling setTimeout with a for
Possible Duplicate: How to use include within a function? i have two file inc.php
Possible Duplicates: While vs. Do While When should I use do-while instead of while
Possible Duplicate: Breaking out of a nested loop I have this code foreach (___)
Possible Duplicate: Inadvertent use of = instead of == C++ compilers let you know
Possible Duplicate: Use Linq to Xml with Xml namespaces I have an xml: <?xml
Possible Duplicate: is while(true) bad programming practice? What's the point of using “while (true)
Possible Duplicate: Is “for(;;)” faster than “while (TRUE)”? If not, why do people use
Possible Duplicate: JavaScript for…in vs for I am using a for loop in my

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.