Paper II: Selection and Iteration Flashcards

1
Q

What are selection functions for?

A

To make a decision between two or more options.

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

What three statements represent selection in pseudocode?

A

IF
ELSE
ELIF or ELSEIF

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

How do you use ELSE IF?

A

You embed the IF construct under the ELSE statement.

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

How is selection represented in flowcharts?

A

With a rhombus shape that has the two options: YES and NO.

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

What is iteration for?

A

Iteration i the process of repeating a set of instructions for a set amount of times or until the desired outcome is reached.

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

What is count controlled iteration?

A

When the number of iterations is known before loop is started.

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

What programming structure is used?

A
FOR loop
e.g.
FOR turns FROM 0 TO 3 DO
       SEND turns TO DISPLAY
END FOR

This will output 0, 1, 2 and 3

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

How do you structure a FOR loop with a step?

A

FOR index FROM 2 TO 10 STEP 2 DO
SEND index TO DISPLAY
END FOR

This will output 2, 4, 6, 8 and 10

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

FOR EACH structure?

A

SET scores TO [9, 6, 7, 3, 9]
FOR EACH score FROM scores DO
SEND score TO DISPLAY
END FOR

This will output 9, 6, 7, 3 and 9

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

What is condition controlled iteration?

A

Used when the number of loops is determined by a condition.

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

What programming structure is used?

A

SET number TO 0
WHILE number <> 3 DO
RECEIVE number FROM (INT)KEYBOARD
END WHILE

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

REPEAT … UNTIL loops?

A

They continue until a condition becomes true.

e.g.
REPEAT
RECIEVE number FROM (INT)KEYBOARD
UNTIL number = 3

It will continue looping until 3 is entered

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

REPEAT … TIMES?

A

This loop will be repeated the number of times indicated.

e.g.
REPEAT 10 TIMES
RECEIVE score FROM (INT)KEYBOARD
END REPEAT

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