AS SSD Program Control Structures Flashcards

(26 cards)

1
Q

How does a program run?

A

It runs in sequence.

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

What is used to disrupt the sequence of a program?

A

Methods are used.

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

What must a method have?

A

It must have a name an a body of code.

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

How it code within a method executed?

A

Code within a method is executed in sequence.

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

Where should every method be called?

A

In the predefined “Main” method.

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

What is repetition?

A

Repetition, which is also called iteration is the idea of repeating blocks of code a certain number of times or until a condition is met.

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

What are the 4 main types of iteration?

A

For, While, Do-While and For-Each.

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

When should a For Loop be used?

A

A For Loop can be used if the number of iterations of the loop is known to the user.

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

What is a for-each loop?

A

A for-each loop will execute some code depending on how many items are in a data structure, such as a list or array.

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

What is not a requirement when using a for-each loop?

A

It is not a requirement to know how many times you have to loop through a list or array.

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

What is a while loop?

A

A while loop will repeat something until a condition is met. These are most useful when you aren’t sure how many times something has to be repeated.

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

What logical operators can be used in a while loop?

A

Any logical operator can be used and it can also have single or multiple conditions.

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

What is a do-while loop?

A

A do-while loop will always ensure that the code inside the loop will execute at least once before checking the condition.

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

What is a do-while loop considered as?

A

It is considered as a “post-test” loop as it checks the condition after running the code once.

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

What is an if statement?

A

An if statement is used when there are multiple conditions which must be checked and one of which must be true in order to execute a price of code.

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

What is this logical operator?

17
Q

What is this logical operators?
!=

18
Q

What is this logical operators?
>

19
Q

What is this logical operator?
>=

A

Greater than or equal to

20
Q

What is this logical operators?
<

21
Q

What is this logical operators?
<=

A

Less than or equal to

22
Q

What is this logical operators?
&&

23
Q

What is this logical operators?
||

24
Q

Why might you use a nested if statement?

A

It allows you to control the program flow within an if statement.

25
What is a switch statement?
A switch statement will execute a condition depending on a condition. It would be considered less complicated to write and to logically follow than an if statement.
26
What happens if not case value matches the switch value?
Then the default output message is outputted to the console.