This loop is called controlled loop in C. it genraly divided in three parts initializaton ,condition and
expression[increment/decrement,etc.] all three parts are optional.
If you do’nt give condition to for looop it become true and run infinit times.
1. for( initializaton ; condition ; expression )
2. for( initializaton ; condition ; expression )
NOTE : remember the ( ; ) semicolon after each part.
initializaton : In this part we can store values in variable those will used by loop statement.
or we can say we can do our initializaton here in this part.
This part of for loop execute first and once only.
condition : you use a lots of condition in while or do-while loop this is same in this part we can write our condition.
This place in for loop is check each time during execution. if condition become false then loop stop executing.
expression : In this part of loop we can write any expression which execute after running body of loop. amd execute each time
loop will execute.
In this loop first of all the initializaton part will execute it will execute once then
or conditional part will execute after initializaton it check every time and if it,s true then loop
will execute after checking the condition the flow of loop will move forwarde
now the body of loop will execute after running hole body of loop
The expression will execute after executing body of loop and
after it again the condition will check and loop will flow continusly untill condition become
Now ready for a lots of question on for loop.