Pages

Breaking News
recent

Looping Statement

Looping Statement

FOR LOOP STATEMENTS:

•It has many parts that include an initialization part, an expression part, and an iteration part
•The initialization does not need to declare a variable as long as the variable is declared before the for statement. So int x=0 and x=0 are both acceptable
•The expression within the for loop must be evaluated to a boolean value
•The iteration, also known as the update part, provides the mechanism that will allow the iteration to occur:
The for statement consists of three elements:
Initialization (i = 0): initializes counter, executed once before the loop begins.
Termination (i < 10): loop repeats, while this expression is correct. It stops, when it becomes false.
Increment (i++): increments counter.

 WHILE STATEMENTS:
•This loop evaluates an expression and executes the loop body only if the expression evaluates to true
 
•There is typically an expression within the body that will affect the result of the expression
 
•The while statement executes its body, while specified condition is true.
 
do-while ITERATION STATEMENT:
 

Unknown

Unknown

No comments:

Post a Comment

Powered by Blogger.