loops Flashcards

1
Q

loops

A

allow for some code to be repeated as many times as a programmer desires

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

initialization

A

*component needed for a loop
*a value assigned to a variable

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

comparison

A

*component needed for a loop
*the value that we want the variable to get to
*the amount of times the loop should occur

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

update

A

*component needed for a loop
*the code that changes the value of the variable in order to reach the desired value

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

for loop syntax

A

for(initialization; comparison; update)
{
//code to be executed
}

*if the comparison evaluated to true, the code is executed and then the update occurs
*flow: initialization, comparison, loop, update, comparison
*the loop continues until the comparison evaluates as false

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

nested for loop

A

a for loop within a for loop

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

while loop

A

*can achieve everything a for loop can
*structured differently than a while loop

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

while loop structure

A

*initialization occurs outside of the loop
*update occurs within the curly braces
while(comparison)
{
//code to be executed
}

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

do while loop structure

A

do
{
//code
//update
} while (comparison);

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

do while loop initialization

A

initialization occurs outside the loop

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