Iteratation Flashcards

1
Q

While loop

A

While (condition) {
Statements;
}

Will always run until condition is false

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

Do-while

A

Loop to be ran prior to condition check and will go back to the top

Do {
Statements;
} while (condition);

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

For loop

A

Runs for a set number of iterations

For (initialisation; condition; Increase/decrease) {
}
Initialise: initialise the variable used for condition

Condition: checks If loop should be executed or not

Increase/decrease: affects variable to check the condition

For (int counter =1; counter <= 10; counter++) {

}

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

Nested loops

A

Loop inside loop

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

Break statement

A

Terminates a loop and code goes back to normal flow, can also be used for switches

EXITS LOOP

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

Continue statement

A

Skips current iteration and continues to next iteration

I .e if we skip 3 of an iteration we go to irritation number 4

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

When does iteration occur in code?

A

After statements have occurred.

So read initialisation see if it meets condition, perform statements then iteration

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