Quick Contact


    C Loops

    The process of continuously carrying out a collection of statements is called looping. The declarations obtain implemented lots of numbers of times based on the condition.

    But if the condition is given up such logic that the repeating continues any type of variety of times with no set condition to quit looping those statements, after that this type of looping is called infinite looping.

    Types of Loops

    There are three types of loops:

    • while loop
    • do-while loop
    • for loop
    while loop:

    while loop is a majority of the fundamental loop in C programming. while loop has one control condition, and also implements as long the problem is true. The condition of the loop is tested before the body of the loop is implemented, therefore it is called an entry-controlled loop.

    Syntax:
    		While (condition)
    		{
      			statement(s);
      			Incrementation;
    		}
    	

    For example:

    C Loops

    Output:

    C Loops
    do-while loop:

    do declaration reviews the body of the loop initially and also at the end, the problem is inspected making use of while statement. It means that the body of the loop will certainly be executed at the very least when, although the beginning problem inside while is initialized to be false.

    Syntax:
    		do
    		{
       			statement(s);
    		}while( condition );
    	
    Example:
    C Loops

    Output:

    C Loops
    For loop:

    for loops is extremely similar to a while loop because it remains to define a block of code till a statement becomes false, and everything is defined in a solitary line. The for loop is likewise an entry-controlled loop.

    Syntax:
    		for ( init; condition; increment )
    		{
    		   	statement(s);
    		}
    	

    Example:

    C Loops

    Output:

    C Loops
    C Control Statement

    Loop control declarations transform implementation from its regular series. When implementation leaves an extent, all automated objects that were developed because the scope is damaged.

    There are three control statement used in C language:

    • break

      When break declaration is come across inside a loop, the loophole is quickly excited as well as the program continues with the statement quickly complying with the loop.

    • Continue

      It creates the control to go straight to the test-condition and afterward proceed with the loophole procedure. On running into continue, the cursor leaves the existing cycle of the loop and starts with the following cycle.

    • goto

      It transfers the current program implementation series to some other part of the program.

    Copyright 1999- Ducat Creative, All rights reserved.