levo

Program Control Structures

Sequence and the order of execution

  • 3 things to know
  • AS Unit 1

Overview

Flow of control in a program and task that is naturally pure sequence.

What you need to know

Answer each one before you reveal it.

Your recallNot started
Process

What does sequence mean as a program control structure?

Key term

Which three basic control structures can any program be built from?

Key term

What is a statement, and what is a compound statement?

Questions from this subtopic

Each one with the model answer underneath.

  1. 1

    What does sequence mean as a program control structure?

    Model answer

    Sequence is the control structure in which statements are carried out one after another in the order they are written, each completing before the next begins.

  2. 2

    Which three basic control structures can any program be built from?

    Model answer

    The three basic control structures are sequence, selection and repetition.

  3. 3

    Using a total calculated from a price as the example, why does the order of statements within a sequence matter?

    Model answer

    A statement can only use values that already exist, so calculating total = price * quantity before price has been assigned uses an unset value and gives the wrong answer or refuses to compile.

  4. 4

    int a = 2; int b = 3; a = a + b; b = a - b; — what are the final values of a and b?

    Model answer

    The third statement makes a equal to 5, and the fourth then makes b equal to 5 minus 3, which is 2, so a finishes at 5 and b at 2.

  5. 5

    In the fragment int p = 2; int q = 3; q = p - q; p = p + q; work through each statement and give the values of p and q at the end.

    Model answer

    The third statement stores 2 minus 3 in q, giving −1, and the fourth then stores 2 plus −1 in p, so p ends at 1 and q at −1.

  6. 6

    Explain why swapping the contents of two variables needs a third variable, and give the three statements in order.

    Model answer

    Assigning one variable to the other destroys the value being overwritten, so a temporary variable must hold it first: temp = a; then a = b; then b = temp.

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.