Program Flow Flashcards

1
Q

What’s the flow of a program?

A

The order that the steps are carried out in.

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

How can you control the program flow?

A

Using selection statements: IF statements and CASE statements.

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

What is an IF statement?

A

Allows you to check if a condition is true or false, and carry out different actions depending on the outcome.

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

What is a nested IF statement?

A

Putting another IF statement inside another.

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

What does a nested IF statement allow?

A
  • check more conditions once you’ve established the previous condition is true.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is IF-ELSEIF statement?

A

Used to check multiple conditions. They’re different from nested IF statements as they only check more conditions if the previous condition is false.

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

What is a SWITCH-CASE statement?

A

Instead of checking if a statement is true or false, it checks if a variable has specific values.

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

What are SWITCH-CASE statements used for?

A

When you want a program to perform different actions for different values of the same variable.

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

How are SWITCH-CASE statements different to IF statements?

A

They have a smilier structure but SWITCH-CASE statements give a neater way to test different values of a variable, this makes them easier than ELSEIF statements to maintain.

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

What is a disadvantage of SWITCH-CASE statements?

A

They can only check the value of one variable.

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

What is a FOR loop?

A

It’ll repeat the code inside a fixed number of times. The number of times that the code repeats will depend on an initial value, end value and the step count.

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

What makes SWITCH-CASE statements more robust?

A

They include a ‘default’ case which tells the program what to do if none of the other cases are correct.

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

What are DO UNTIL loops?

A
  • controlled by a condition at the end of the loop.
  • keep going until the condition is true (i.e. while it’s false)
  • always run the code inside them at least once
  • you get an infinite loop if the condition is never true
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are WHILE loops?

A
  • controlled by a condition at the start of the loop
  • keep going while the condition is true (i.e. until it’s false)
  • never run the code inside them if the condition is initially false
  • you get an infinite loop is the condition is always true.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are DO WHILE loops?

A
  • controlled by a condition at the end of the loop
  • keep going while the condition is true (i.e. until it’s false)
  • always run the code inside them at least once.
  • you get an infinite loop if the condition is always true.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly