A loop can repeat the statement of a particular job continuously
for a specific number of times.
Loop
|
Description
|
Syntax
|
For
|
The condition can tested before statement execution.
|
For(Initialization, Final condition, increment /decrements )
{ statement;
}
|
while
|
First it check the condition then do the job.
|
Initialization;
While(Final condition) {
Statement;
increment /decrements; }
|
Do..while
|
First do job then test the condition.
|
Initialization;
Do{ Statement;
increment /decrements; } While(Final condition)
|
A loop can control data execution by using its three parts
Initialization: in this part of the for loop can
declared the starting point of for loop. That’s means initial point of statement
execution .in the program the red block are indicate initialization.
Final condition: the end point of program. The ending period statement execution , that defined by the final condition. In the
program the green block are indicate the final condition.
3Increment
/decrements: The increment operators are use to increases the values of its operand and decrements operators are use to increases the values of its operand. in the program yellow box are indicate increment.
Flow chart on for loop
Comments
Post a Comment