for loop
for loop C programing :
The for loop is another entry-controlled loop that provides a more concise loop control structure .the general form of the for loop is
The execution of for statement is as followes :
for(intialization ; tes -condition ; increment / decrement )
{
body of the loop
}
The execution of for statement is as followes :
- Initalization of the control variables is done first , using assigenment statements such as i =1 and count =0. The vaiables i and count are known as loop -contrl variables .
- The value of the control variable is tested using the test-condition . The test-condition is a relational expression , surch as i < 10 that determines when the loop will wxit . If the condition is ture , the body of the loop is executed ; otherwise the loop is terminated and the execution continues with the statement the immediately follows the loop.
- When the body of the loop is executed , the control is transferred back to the for statement after evaluating the last statement in the loop . Now the control variable is incremented using an assignment statement such as i = i+1 and the new value if the control variabel is again tested to see whether it satisfies the loop condition . If the condition is satisfied , the body of the loop is again executed . This process continues till the value of the control variable fails to satisfy the test-condition .


No comments