• Call Us: +91 9437911966
  • Email Us: info@studentstutorial.com
  • Home
  • C Examples
  • Server Side
    • PHP
    • Java
    • CodeIgniter
    • Laravel
    • JSP
    • JDBC
  • Frontend
    • HTML
    • CSS
    • Javascript
    • jQuery
    • AJAX
    • FPDF
    • TCPDF
  • APP & DB
    • Android
    • Cordova
    • SQL
    • Oracle
  • Project
C Tutorial C Introduction C Characteristic C Comments C Operator C Assign Operator C Arithmetic Oper.. C Logical Operator C Modulus Operator C Variable C Initialise Variable C Print F C Translators C Programming C Control Flow C If Else Statement C Nested If Else C Loops C While Loops C For Loops C Do While C Nested Loops

C For Loop

  • Students Tutorial
  • 08 jun 2020
   

When we are working with for loop it contains 3 parts-

  1. Initialisation
  2. Condition
  3. Iteration

Syntax

For (initialization; Condition; iteration)
	   {

			   Statement block;

		}
	

When we are working with a for loop, the execution process will start from initialisation.

Initialisation part will be executed only once when we are passing the control within the body the first time.

After execution of initialisation part, control will pass to condition, if condition evaluate is true, then control will pass to statement block.

After execution of statement block, control will pass to iteration, from iteration-once again it will pass block to condition.

Always repetition will come b/w condition, statement block and iteration only.

When we are working with a loop, everything is optimal but mandatory to place 2 semicolons.

While ( ) → error
For (; ;) → Valid

When the condition part is not given in for loop, then it repeats infinite times because the condition part is replaced with non – zero value (True value).

When we are working with a FOR loop, it repeats in an anti-clock direction.

Always pre checking the process occurs when we are working with FOR loop i.e. by execution of statement block condition part is executed.

While (0) → No repetition
For (; 0 ;) → I’s it will repeat

In for loop, when the condition part is replaced with constant 0 then it repeats once, because no.of instances became 1 at the time of compilation.

Int I;
I = c;
While (i); No repetition
For (; I;)

Programming:

Void main ( )
{

Int I;

For (i=1; i< = 10; i= l+2)

Print f (“%d”, i);

}

   O/p: 1 3 5 7 9
 
Student Tutorial is a online tutorial for web design and development. Here you can find easy example and explanation for each tutorial.
Copyright © 2016-2025 Student Tutorial

Server Side

  • PHP
  • Java
  • CodeIgniter
  • Laravel
  • JSP
  • JDBC

Frontend

  • HTML
  • CSS
  • Javascript
  • jQuery
  • AJAX
  • FPDF

App & Database

  • Android
  • Cordova
  • SQL
  • Oracle