levo

Program Control Structures

Sequence and the order of execution

  • 3 things to know
  • AS Unit 1
Start revising · £5/month

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.

Everything in your subscription

Runs, plus a mode for every other kind of session.

1Flash
2Imposter
3Fade
4Brain dump

Learn every subtopic in runs of four questions

Facts flash and fade, a wrong word hides in some of them, and a brain dump decides which questions are locked in.

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

Cram the night before, weakest topic first

A quick scan finds your weakest topics. Recall each fact you missed three times in a row.

A null is the of one.
absencepresencetype

Blank Blitz consolidates the facts

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

✓What it iscovered
~Why it happenspartly there
How long it lastsnot there yet

Explain It tests your understanding

Explain a concept in your own words and see which of its points you covered.

An error is the mistake a person made.
TrueFalse

Test It catches misconceptions

Spot the fault in a statement. The faults are the mistakes students make most often.

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.

Learn it in runs of four questions, each ending on a brain dump against the clock. Every question you lock in comes back the next day, then at longer gaps, each time just before you would forget it.

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