Module 6: Loops Flashcards

1
Q

for loop

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

while loop

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

do-while loop

A

repeatedly executes a block of statements until a specified Boolean expression evaluates to false. Will always execute the code at least once before checking if the condition is true.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

enhanced for loop (for-each loop)

A

a for loop that iterates through each element in an array or Collection

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

for loop syntax

A

for ( int - variable you want to create for loop; condition; updates variable being used in condition ++ or - -)
{
statement(s);
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

while loop syntax

A

while (condition)
{
statement(s);
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

enhanced for loop (for-each loop) syntax

A

for(data_type variable : array | collection){
//body of for-each loop
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

do while loop syntax

A

do
{
statement(s);
} while (condition);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is needed for a nested loop?

A

You can use one statement inside another statement.

for ( initialization; condition; increment) {
for ( initialization; condition; increment) {
// statement of inside loop
}
// statement of outside loop
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly