levo

Program Control Structures

Choosing and evaluating control structures

  • 3 things to know
  • AS Unit 1

Overview

Three measures of a well-chosen control structure and structured programming.

What you need to know

Answer each one before you reveal it.

Your recallNot started
Evaluation

Evaluate the choice between a switch and an else-if ladder for a menu of six numbered options.

Key term

What is structured programming, and what does the single entry and single exit principle require?

Key term

Compare a loop that tests before the body with one that tests after, and give a case that suits each.

Questions from this subtopic

Each one with the model answer underneath.

  1. 1

    Which control structure suits a task where an action is taken only for certain data values?

    Model answer

    Selection suits that task, because selection evaluates a condition and executes the statements only when the condition holds.

  2. 2

    Which loop structure suits a fixed number of passes, and which suits a number decided by the data?

    Model answer

    A counted for loop suits a fixed number of passes, and a while or do while loop suits a number of passes decided by the data as the loop runs.

  3. 3

    Evaluate the choice between a switch and an else-if ladder for a menu of six numbered options.

    Model answer

    A switch is the better choice, because the six options are distinct constant values, the tested variable is written once, and adding a seventh option is a single new case; an else-if ladder would repeat the comparison six times.

  4. 4

    Why does replacing ten near-identical copied statements with a loop reduce defects?

    Model answer

    The logic then exists in one place, so a correction is made once rather than ten times and there is no risk that one of the copies is missed or edited differently.

  5. 5

    What are three measures of a well-chosen control structure?

    Model answer

    A well-chosen structure expresses the intention plainly to a reader, behaves correctly at the boundary values of its data, and does no more work than the task requires.

  6. 6

    What is structured programming, and what does the single entry and single exit principle require?

    Model answer

    Structured programming builds a program only from sequence, selection and repetition, and the principle requires each such block to be entered at one point and left at one point, so a block can be reasoned about as a single step.

Other ways to work this

The same content, four other ways.

What is inside Levo

Six ways to work the same material.

1Closed book
2Open book
3Closed book

The 3-step method, run for you

Answer cold, learn it, then prove it stuck. Levo tracks the jump between your first attempt and your last.

Software and the Development Environment
Defining Data: Types, Variables and Classes
Program Control Structures
Objects, Classes and Data Structures

Cram a whole paper in one sitting

Sort every topic into what you know and what you do not, then drill only the weak ones.

A null is the of one.
absencepresencetype

Blank Blitz makes facts automatic

Rapid timed gap-fills on the terms and numbers you need to recall without thinking.

AA null means no value has been recorded.
BZero and an empty string are values.
CA null is the absence of a value.

Build It gets the exam shape right

Assemble a full-mark answer from its marking points, in the order an examiner wants them.

An error is the mistake a person made.
TrueFalse

Test It catches misconceptions

Spot the fault in a statement. The traps are the mistakes students actually make.

721941163128510

Brain Breaks between sessions

Short focus games to reset attention, so the next set lands better than the last.

Every question in Program Control Structures, on a schedule.

Attempt a question from memory, write the correct version, then attempt it again. Levo records the jump between your first attempt and your last, and brings each question back on the day you are due to forget it.

Or £46 a year, about £3.83 a month. Cancel anytime.