BrainDump
  Home arrow BrainDump arrow Page 4 - C:Loops
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
BRAINDUMP

C:Loops
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 28
    2008-03-17

    Table of Contents:
  • C:Loops
  • While You Were Away
  • Do it While You Can
  • The Break And Continue Statement

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    C:Loops - The Break And Continue Statement


    (Page 4 of 4 )

    Sometimes you may wish to break out of a loop even if the criteria has not been met to end the loop. Similarly you can force a program to reiterate a loop from the start, skipping over the elements of the loop following the Continue statement. Break also breaks out instantly from a loop, not bothering to carry out the rest of it. Here is an example with an infinite loop that counts to ten, then a continue forces it to count to 11, even though the break should (and eventually does) break out of the loop. Here it is:


    #include <stdio.h>

    int main()

    {

    int x=0;

    for(;;)

    {

    x++;

    if(x<=10)

    {

    printf("%d, ",x);

    continue;

    }

    printf("%d is greater than 10 fool!n",x);

    break;

    }

    return(0);

    }

    Here is the result of this program:

      1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 is greater than 10 fool!

    <Note: The for(;;) creates an infinite loop>

    Conclusion

    We didn't cover everything in this tutorial related to loops, such as nesting loops, but we did cover a lot of ground and will hopefully explain things in more detail further down the pipe. For now though you should have a good place to start on your programming. I'll be posting more articles in this series in the near future, so be sure to check back often. Thanks.

    Till then...


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · Hey, welcome to my article on C Loops. where we discuss the different types of loops...
       · Thankyou for the information its in very simple and understandable...
     

    BRAINDUMP ARTICLES

    - Introduction to Office Live Workspace
    - Using MS Excel for One-way Analysis of Varia...
    - Comparing Data Sets Using Statistical Analys...
    - Import Blogger Posts into WordPress Using Wi...
    - Download WordPress from an FTP Server and Ru...
    - Install and Run WordPress in XAMPP Local Host
    - What Windows 7 Brings to the Table
    - Virtualization and Sandbox Detection
    - Advanced Firebug Techniques in Windows XP Ho...
    - Editing CSS with Firebug in Windows XP Home
    - Using Firebug in Windows XP Home
    - Migrating to Exchange Server 2007
    - Using System Restore on a Non-Bootable PC
    - Finding Logged on Users and More Scripting S...
    - Developing Macro Commands in MS Excel





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek