Trusted by students across multiple disciplines!
For loop - Answer: A typical looping construct designed to make it easy to repeat a
section of code using a counter variable. The for loop combines the creation of a
variable, a boolean looping condition, and an update to the variable (increment or
decrement) in one statement.
While loop - Answer: programming construct used to repeat a set of commands (loop)
as long as (while) a boolean condition is true. Will check if the condition is true before
entering the body.
Do-while loop - Answer: repeatedly executes a block of statements until a specified
Boolean expression evaluates to false. Will always execute the code at least once
before checking the if the condition is true.
Enhanced for loop (for-each loop) - Answer: a for loop that iterates through each
element in an array or Collection
For loop syntax - Answer: for ( init; condition; increment )
{
Statement(s);
}
While loop syntax - Answer: while (condition)
{
Statement(s);
}
Enhanced for loop (for-each loop) syntax - Answer: for(data_type variable : array |
collection){
//body of for-each loop
1
APPHIA - Crafted with Care and Precision for Academic Excellence.