LEARNING AREA 5 – PROGRAMMING



LEARNING AREA 5 – PROGRAMMING

5.1 Basic Programming Concepts

5.1.1 Define Program and Programming Language

5.1.1.1 State the definition of program

5.1.1.2 State the definition of programming language

5.1.2 Level and Generation of Programming Languages

5.1.2.1 Identify the generation of low-level programming language with examples.

|Low Level |Description |Examples |

|First Generation – 1GL |Machine language is a set of instructions and data (written in |Machine language |

| |binary code) that a computer's can execute directly. | |

|Second Generation – 2 GL |Assembly language is the human-readable notation for the machine |Assembly language |

| |language used to control specific computer operations. | |

5.1.2.2 Identify the generation of high-level programming languages with examples

|High Level |Description |Examples |

|Third Generation language |Procedural language uses a series of English-like words, |PASCAL, FORTRAN, COBOL, BASIC, C, ADA |

| |that are closer to human language, to write instructions. | |

|Fourth Generation Language – |Non-procedural language, enables users to access data in a|SQL, NOMAD anf Focus |

|4GL |database. | |

|Fifth generation _ 5GL |Provides a visual or graphical interface, (visual |Prolog and Mercury |

|(natural language) |programming environment) | |

| |Allows people to interact with computers without needing | |

| |any specialised knowledge. | |

5.1.3 Programming Language Approaches

5.1.3.3 Differentiate between structured approach and object-oriented approach in programming.

|Structured Programming |Object Oriented Programming |

|Uses a top-down design model- |Uses objects |

|The whole program is broken down into | |

|smaller section that are known as |Combines data with functions to create objects. |

|modules | |

|Always use for organizing and coding computer programs which |Every object has relationship with one another |

|employ a hierarchy of modules | |

|Control is passed only through the hierarchy |Eg: Smalltalk,Java, Visual Basic, C++ |

|Eg: Ada, Pascal, Fotran | |

5.1.4 Translator

5.1.4.1 Describe the translation method of programming using assembler, interpreter and compiler

|Translation Method |Description |

|1. Assembler |An assembler is a computer program for translating assembly language — essentially, a mnemonic |

| |representation of machine language — into machine language. |

| |Example : MACRO-80 Assembler and Microsoft MASM |

|2. Interpreter |Interpreter is used to interpret and execute program directly from its source without compiling it first.|

| |Example: BASIC, Logo and Smalltalk. |

|3. Compiler |The source code (in text format) will be converted into machine code which is a file consisting of binary|

| |machine code that can be executed on a computer. If the compiler encounters any errors, it records them |

| |in the program-listing file. |

| |Example: C++, Pascal and COBOL |

5.1.4 Basic Elements in Programming

5.1.5.1 Differentiate between constants and variables

5.1.5.2 Differentiate between data types: Boolean, integer, double, string and date.

|DATA TYPES |DESCRIPTION |DECLARATION |

|Boolean |consists either a True or False value. Programmers usually |Const Input_Status = true |

| |use it to store status. |or |

| | |Dim Input_status As Boolen |

| | |Input Status = False |

|Integer |contains any whole number value that does not have any |Const year_birth = 1998 |

| |fractional part. |or |

| | |Dim age As Integer |

| | |Age = 17 |

|Double |Any number value that may and could contain a fractional |Const PI = 3.142 |

| |part. |or |

| | |Dim Marks As Double |

| | |Marks = 60.5 |

|String |contains a sequence of characters |Const Name = “CHOO” |

| | |or |

| | |Dim Address As String |

| | |Address = “Kuala Lumpur” |

|Date |Contain date and time value |Example: 7/8/91, 12:28 AM |

5.1.5.3 Differentiate between mathematical and logical (Boolean) operators.

|Operators |Function |Examples |

|Mathematical |Mathematical operators perform mathematical operations such as plus |+ , - , * , / |

| |or substract | |

|Logical |Logical operators perform logical operations such as checking the |AND, OR , NOT |

| |condition of two Boolean values. | |

|Relational |Relational operators perform element-by-element comparisons between |=, , < > , = |

|( Comparison ) |two arrays (elements).. | |

5.1.5.4 Differentiate between sequence control structure and selection control structure.

| |Sequence Control Structure |Selection Control Structure |

|Execution Flow |Executes statement one by one in linear or |Executes different statements for different |

| |consecutive order |condition |

|Usage |Use when want to execute code line by line |Use when want to implement decision making process|

| | |in the program |

| |Does not use the decision symbol |Use the decision symbol |

|Flowchart | | |

| | | |

| | | |

| | | |

| | | |

| | | |

| | | |

| | | |

| | | |

| | | |

| | | |

| | | |

| | | |

| | | |

| | | |

| | | |

5.2 Programming Development

5.2.1 Apply Program Development Phases To Develop A Problem-Solving Program

5.2.2 Program Development Phases

1. ANALYSIS PHASE

• The programmer will interview the client to find out what the client’s needs are.

• Identify input, processing, output and data component.

• Ask expert,refer to book and website.

• Meet with the system analyst and user.

For example, the client might be a school that wishes to set up a school registration program. So the school administrator might tell the programmer that they need to record students’ data such as name, date of birth, gender, class, parents’ names, address and contact numbers.

2. PROGRAM DESIGN PHASE

• The programmer will divide all program activities into program modules

• Create solution algorithm for each program modules

• Write an outline of the logic(pseudo code) of the program.

• Design a flow chart.

• Design user interface

Pseudo code

Flow Chart

|Elements |Graphical Form |

|Terminal | |

|(beginning or ending of program) | |

|Flow line | |

|( to connect symbols and indicate the sequences of operation) | |

|Input/Output | |

|(enter data or display information) | |

|Process | |

|(a process to be carried out) | |

|Decision | |

|(condition that determines a specified path to follow) | |

| | |

|Connector | |

|(entry from or exit to another part) | |

3. CODING PHASE

• Translating the algorithm into programming language.(usually on paper)

• After finishing the coding process, the programmer will type the programming language code into the computer.(eg.Pascal,C++ and Visual Basic)

4. TESTING AND DEBUGGING PHASE

• Is to ensure the program runs correctly without any syntax or logic errors.

• If errors are uncovered during testing, the programmer will proceed to debugging.

• Debugging involves tracing the source of errors in the program and making the necessary corrections.

5. DOCUMENTATION PHASE

• Documentation refers to the written material generated throughout all the phases of program development.

• Thus documentation includes the detailed problem definition, the program plan (flow chart or pseudo code), comments within the source program and testing procedures.

• A detailed description of the program, clear layouts of input and output records and a program listing.

5.3 Current And Future Developments

5.3.1 Fifth Generation Language

5.3.2 Natural Language

5.3.3 OpenGL (Graphic Library)

-----------------------

A computer program is a series of organized instructions that directs a computer to perform tasks

A programming language is a set of words, symbols and codes that enables humans to communicate with computers.

Programming Approaches

STRUCTURED PROGRAMMING

Uses a top

down design model means that the whole program is broken down into smaller sections that are known as modules.

Examples:

Ada, Pascal and Fortran

OBJECT-ORIENTED

Refers to a special type of programming approach that combines data with functions to create objects.

Examples:

C++ and Java are complete object-oriented languages

Low level language

Translate to

Machine code

Using :

• ASSEMBLER



Using :

• INTERPRETER

Machine code

High level language

Using :

• COMPILER



Machine code

High level language

Translate to

Translate to

Object code

Translate to

| |Constants |variables |

|characteristics |Value is not changeable during the course of |Value can be changed anytime during the course|

| |the program |of the program |

|usage |Use constant when you want to declare |Use variable to store data that may or will |

| |something that won’t change midway in your |change during the running of the program. |

| |program execution. | |

PROBLEM ANALYSIS PHASE

DESIGN PHASE

CODING PHASE

DOCUMENTATION PHASE

TESTING AND DEBUGGING PHASE

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download