TOPIC 3: PROGRAMMING TOOLS AND TECHNIQUES

Topic 3.1. Problem-Solving Techniques

Computer languages may be classified as being either low-level or high-level language:

LOW-LEVEL LANGUAGES

The characteristics of low-level languages are:

HIGH-LEVEL LANGUAGES

The characteristics of high-level languages are:

SELECTING A PROGRAMMING LANGUAGE

When a program or complete suite of programs needs to be written for a particular problem, selection of the language may be based on:


A PASCAL PROGRAM (TPW)

As a first example, consider a program that calculates an electricity bill. The standing charge is £7.41 per quarter, and the unit rate is 6.5 pence per unit. The number of units used this quarter is 1200.

program elec; {a program to calculate electricity bills}

var

     standing_charge : real; { the fixed quarterly charge }

     unit_rate : real;

    units_used : integer;

    total_bill : real;

begin

    standing_charge := 7.41;

    unit_rate := 0.065; {converted to £}

    units_used := 1200;

    total_bill := standing_charge + (unit_rate * units_used);

    writeln('Total amoung payable', total_bill)

end.

THE PARTS OF A PROGRAM

The Pascal program shown above consists of 3 parts:

STEP 1. the Program heading, consisting of the word program and a program name of our choice.

STEP 2. A declaration of each item of data to be used by the program.

STEP 3. A sequence of actions (statement) enclosed between the words begin and end.

COMMENTS

The comment may occur anywhere in the program and is enclosed in curly brackets { }, or alternatively (* *) may be used. Comments are ignored by the compiler.

VARIABLE DECLARATION

THE STATEMENT OF THE PROGRAM


RESOURCE:

P M Heatcote, [A Level Computing, 3rd Edition], Ashford Colour Press Ltd, 1996.

Hosted by www.Geocities.ws

1