GNVQ Advanced IT


Unit 6 Software - Features of Computer Programs  See also High Level Languages


Tutor 


The features of a computer program include the code, program structures, data types, data structures, program constructs, expressions and operators andmethod of translation.  We can further describe these as follows:-


Code
When a program is written in a computer language, it is said to be "in code".  Translating a program design into a computer language is called encoding.


Program Structure
A program with a clear simple structure is more likely to work than one with a convoluted structure.  It is worth planning the structure carefully and using subroutines as much as possible.  Designing the program structure or indicating the plan of an existing program can be done in various ways, using flowcharts, structure diagrams, pseudo-code for example.


Program Constructs

Possible program constructs:
 



Data Types
Data can be stored as either a constant (it does not change) or variable.  The values of variables can be altered during the running of the program.

Data is stored in computer memory and the translation program has to decide where to store the data and how much space to reserve, so the program code must indicate what type of data is to be stored.

Data types can be
 



Data Structures

Common structures
 



Expressions and Operators

There are three basic types of programming expressions:
 

The operators associated with arithmetic expressions are:

        +    -    /    *    ^
    E.g.
    count:=count + 1
    average:=total/count

Relational operators

     =    <    >    <=    >=    <>
    e.g. IF salary < 4000 THEN tax:=0

Logical operators:  NOT  AND  OR  see also Boolean operator

    e.g. IF mark >=70 AND mark <=80 THEN grade:= "B"

An operator which is not concerned with any of the above expressions is:  concatenation.  this is the term applied to string manipulation, in particular the joining of one or more strings together to form another string.

e.g. fullname:= title + firstname + surname

The + operator in this instance is not adding numerically but joining



Methods of translation
All programs have to be translated into machine code before the computer can actually run them. Assembly language programs are translated by an assembler, whilst high level language programs are translated either by a compiler or an interpreter.

Compiler:
A compiler attempts to translate all the source code (instructions you have written) at one go into the 'native' language of the computer (1010101010101010); flagging any syntax errors it finds in the process.  Linking of the object code produced and running the resultant executable file is done as a separate process.

Humans find the machine code (1010101010101010), which the computer understands, unnatural, difficult and innefficient to use.  Therefore very few programs are written directly in this language.

Pascal is an example of a high level language, closer to English.  It is a compromise, going halfway to meet the computer.  The role of a compiler is that of a translator; taking the high level program created and completes the translation into the native machine code of the computer.  This final code is sometimes referred to as object code)

Because a high level language such as Pascal is highly structured the compiler can fulfill another duty (error checking) by ensuring that the object code is correctly formed according to the rules of Pascal.  If any syntax errors are detected it is reported back to the user who then needs to re-edit the source code and re-compile.

Interpreter:
An intepreter differs from a compiler, as it attempts to translate and then run each statement in turn.  This is a slower method than compilation, since translation is necessary every time the program is run.  A second disadvantage is that since the interpreter stops when an error is encountered or the end of the program is reached, only the first error is found in each run.

see also script, JavaScript and VBScript



 
 Top of Page
Home Page
Query for Tutor?