What is For Loop?

0

What is For Loop?

For loop is the Entry Control loop It's having 3 parts Initialisation,Condition,Increment/Decrement All 3 parts are optional. you can skip all or anyone according to your need.
  1. All parts(Initialisation,Condition,Increment/Decrement)

    for(initialisation; condition; increment/decrement)
        {
    
            //Loop body Instructions 
            //this is a place where you write a set of statements perform again and again
        }
                    
                    
                                            
  2. With 2 parts(Initialisation,Condition,Increment/Decrement)
    Initialisation
    for( ;Condition;Increment/Decrement)
    {
      //Loop body Instructions 
      //this is a place where you write a set of statements perform again and again
    }
    
  3. With 2 parts(Initialisation,Condition,Increment/Decrement)

    for(  initialisation;    ;Increment/Decrement)
     {    //Loop body Instructions 
         // There must be one Break statement otherwise it becomes Infinite (∞) 
        //this is a place where you write set of statements perform again and again 
    }   
    
    

  4. With 2 parts(Initialisation,Condition,Increment/Decrement)
    for( initialisation  ;condition;)
    {
     //Loop body Instructions 
     //this is place where you write set of statements perform again and again
     //increment/decrement/some operation with initialised variable otherwise this loop act as  Infinite Loop (∞) 
    }
    
    

  5. With 2 parts(Initialisation,Condition,Increment/Decrement)
    for( ;  ; )
    {
                                                            
            //Loop body Instructions 
            //this is a place where you write a set of statements perform again and again   
    
    }




Post a Comment

0Comments

We you have any doubt let me know :)

Post a Comment (0)
To Top