You are on page 1of 10



Basic Programming Concept ( 5.1 )

Define Program and Programming Language ( 5.1.1 )

State the definition of program ( )

A computer program is a set of instructions given to the computer to perform any


State the definition of programming language ( )

A programming language is a set of words, symbols and codes that enables

human to communicate with computers.

Words (Dim, If, Then, For,
Example of programming language:-
Dim number1 as Integer
Dim number2 as Integer Symbol (=, +, -, *, /)
number1 = 10
number2 = 20
code If total = number1 + number2 Then
s Print “Excellent”
Print “Please try again”
End If

Levels and Generations Of Programming Languages (5.1.2)

Identify the generations of low-level programming languages with

examples. (

Low-level programming

First Generation Second Generation

Machine Language Assembly Language
First Generation:
• Language that computers can execute directly.
• Instructions in this language are in the form of binary digits 1s and 0s.
• Examples : Machine Language

101000010011001101 – Statement for adding two

101000100011001101 – Statement for subtracting two

Second Generation (Assembly language):

• Uses symbolic instructions (mnemonics) to represent the instructions in the
• Examples : AUTOCODER, SAP and SPS

ADD R1 R2 – Adds two numbers stored in registers R1 and R2.

SUB R1 R2 – Is the instruction to subtract two numbers stored in the
Identify the generations of high-level programming languages with
examples (

High-level programming

Third Generation Forth Generation Fifth Generation

COBOL, BASIC, C, SQL, NOMAD, Prolog and Mercury
ADA FOCUS, Intellect

Third Generation
• Uses a series of English words and mathematical symbols for writing programs
to write instructions.
• Example: COBOL, BASIC, C and ADA

Forth Generation
• A very high-level programming language
• Non-procedural language enables users to access data in a database.
• Example: SQL

Fifth Generation
• Visual programming language (natural language).
• Provides a visual or graphical interface, called a
visual programming environment, for
creating source codes.
• Example: Prolog and Mercury
Programming Language Approaches (5.1.3)

Programming Languages

Structured Approach Object-Oriented

Define structured approach in programming (

• uses a top-down design model where developers map out the overall
program structure into separate subsections from top to bottom and also
known as modules

• Example : C, Pascal and Fortran

Define object-oriented approach in programming (

• Refers to a special type of programming approach that combines data with

functions to create objects.

• Example : C++, Java and Visual Basic

Differentiate between Structured approach and Object-Oriented

approach in programming (
Structured Differences Object-Oriented
Approach Approach
Top down design Model Objects
Medium Programming Usage Large Programming
Project Project
C Example C++

Translator (5.1.4)


Assembler Interpreter Compiler

Describe the Translation Method of Programming Using Assembler,

Interpreter and Compiler (

• An assembler is a computer program that translates assembly language
into machine language.
• For example in Intel 80836, the assembly language for the ’no
operation’ command is NOP and its machine code representation is
• Examples of assemblers are MACRO-80 Assembler and Microsoft MASM.

• An interpreter is a computer program that translates a high-level
language into machine language.
• Translate programming statement of a program into machine language.
• Translate programming statement line by line and execute it
• No object code saves.
• Interpreter code run slower
• Examples of interpreter-based language are BASIC, Logo and Smalltalk.
• Compiler is a program that translates a high-level language into
machine language.
• Compiler translates entire programming statement and executes it
• Save machine language in an object code on the disk.
• Compiled code run faster.
• Several programming languages like C++, Pascal and COBOL used
compilers as their translators.

Basic Elements in Programming (5.1.5)

Differentiate between constants and variables. (

Constants Variables
Value is not changeable
Value can be changed
Characteris during the course of the
anytime during the course
tics program.
of the program.
Use constant when you
Use variable to store data
want to declare something
that may or will change
Usage that won’t be changed
during the running of the
midway in your program

Differentiate between the data types: Boolean, integer, double, string

and date (

Data type determines the type of data a variable can store, for example a number
or a character. Examples of data types are integer, double, string and Boolean.

Data type Size Example

Integer 2 bytes To declare an integer as constant in
Contains any whole number VB:
value that does not have any Const Year_Birth =2004
fractional part.
To declare an integer as variable in
Dim Age As Integer
Age =6

Double 2 bytes To declare a double as constant in

Any number values that VB:
contain a fractional part Dim Mark As Double
separated by decimal point. Marks =68.5

String 1 byte To declare string as constant in VB:

Non-numerical and is used to per Const Name = “IMRAN”
store characters and words. character
To declare string as variable in VB:
Dim Address As String
Address = “Alor Setar”

Boolean 2 bytes To declare a boolean as constant in

Value either false or true. VB:
Const Input_Status = true
Programmers usually use it to
store status. To declare a boolean as variable in
Dim Input_Status As Boolean
Input_Status = true

Long Integer 4 bytes Dim Loan As Long

Single-precision floating 4 bytes Dim Price As Single
Double-precision floating 8 bytes Dim Pi As Double
Currency 8 bytes Dim Debt As Currency

Differentiate between mathematical and logical (Boolean) operators


Operator is a symbol or notation that tells a computer to perform certain actions

or operations. An example: the plus (+) notation will tell the computer to perform
the "add" operation.

Operato Mathematical Logical Operators Relational

rs Operators Operators
Function Mathematical Logical operators Relational operators
operators perform perform logical perform element-by-
mathematical operations such as element
operations such as checking the comparisons
plus or subtracts. condition of two between two arrays.
Boolean values.

Used to combine two

simple statements
into a compound

Symbol +(plus) AND >(greater than)

-(minus) OR <(less than)
*(multiply) NOT >=(greater or equal)
/(divide) <=(less or equal)
Example 2 * 5 = 10 G AND H G<H

Differentiate between sequence control structure and selection control

structure (

Aspects Sequence Control Selection Control

• Use to implement code • Use to implement decision
line by line. making process in the program.
• Does not use the • Use the decision symbol.
decision symbol.
Execution • Execute statement one • Execute different statement for
by one in linear or different conditions.
consecutive order.

Flow Chart

Five basic elements in programming are:
• Constant
• Variable
• Data Type
• Operators
• Control Structures


Constant is a data container that stores information. The value will never change
(remains constant) at any time during the course of a program.
Declare is the official term used in programming to announce to the program the
condition of statement in programming.


Variable is a data container that stores information. The value inside may change
at any time during the course of a program.

Data types

Data types Example

String “This is String”
Integer 1, 45, 78
Double 1.25, 3.5
Operator is a symbol that tells what action to perform

Operator symbol
+ (plus) >(greater than)
-(minus) <(less than)
/(divided) =(equal to)
*(multiplied) <>(not equal to)

Control structures
Control structures allow the programmer to control the flow of a program.

Program Development (5.2)

Program Development Phase (5.2.1)

Describe the five main phases in programming development (

Problem Analysis

• Identify input, process, output and data

• Refer to book and website, ask expert and meet with system analyst and
• Example: client need to set up a School registration program. School
administrator (user) 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).

Program Design
• Create a solution algorithm for each modules (logic structure)

• A set of specific procedures, which consists of, step by step instructions to

solve the problem must be develop.(pseudo code)

• Design a flow chart (logical sequence) that represents the needs of the

• Design user interface

• Coding is the next step after the program logic has been formulated using
the appropriate programming language such as C++ and Visual Basic

Testing and Debugging Phase

• The program done will be tested to ensure that is error free.

• The usual error is the syntax error, logic error and run-time error.
• Example: Manually testing using sample data. The program is run through
a computer using a translator program. Errors will be identified by the

Documentation Phase

• Programmer will complete the documentation for the program.

• Produce a description of the program, layouts of the input and output
record and a program listing.
• Example: User manual

1. Shelly Cashman, (2010). Discovering Computer
2. CD Courseware KPM