Basic Programming Concept: Program
Basic Programming Concept: Program
PROGRAM
PROGRAMMING
Programming is a creation of a set of
commands or instructions which directs a
computer in carrying out a task.
2
Ramadan, SMK Pekan 2007
LESSON 2
GENERATIONS OF PROGRAMMING LANGUAGE
3
Ramadan, SMK Pekan 2007
4
Ramadan, SMK Pekan 2007
5
Ramadan, SMK Pekan 2007
SQL, NOMAD and FOCUS are examples of fourth generation programming
languages.
People can talk to computers and the voice recognition systems can convert
spoken sounds into written words, but these systems do not understand
what they are writing; they simply take dictation.
LESSON 3
PROGRAMING APPROACHES
OBJECT-ORIENTED PROGRAMMING
The object-oriented approach refers to a special type of programming
approach that combines data with functions to create objects.
8
Ramadan, SMK Pekan 2007
DIFFERENCE BETWEEN STRUCTURED AND OBJECT
ORIENTED PROGRAMMING
LESSON 4
TRANSLATOR
Sometimes two people cannot understand each other because they don’t
speak the same language. So they need the help of a third person who
understands both languages. This third person is known as a translator.
However, in order for the computer to be able to carry out the instructions,
the high-level languages must be translated into machine language before
the computer can understand and execute the instructions in the program.
PROGRAM
Have you ever wondered how your computer runs your favourite software?
Your favourite software is a program that consists of several instructions that
perform its operation.
The computer will load the machine code and run the program.
ASSEMBLER
An assembler is a computer program for translating assembly language —
essentially, a mnemonic representation of machine 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 10010000.
INTERPRETER
Interpreter is used to interpret and execute
program directly from its source without
compiling it first. The source code of an
interpreted language is interpreted and executed
in real time when the user execute it.
10
Ramadan, SMK Pekan 2007
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.
LESSON 5
HOW TO INSTALL VISUAL BASIC 6.0
The word “ Visual” refers to the technique used to build the Graphical User
Interface (GUI). Visual Basic features an easy “drag and drop” method to
produce an interactive Graphical User Interface (GUI) for your program.
11
Ramadan, SMK Pekan 2007
LESSON 6
BASIC ELEMENT IN PROGRAMMING
12
Ramadan, SMK Pekan 2007
1. Constant.
2. Variable.
3. Data Type.
4. Operators.
5. Control Structures.
Constants
Constant is a data container that stores information. The value will never
change (remains constant) at any time during the course of a program.
Variables
Variable is a data container that stores information. The value inside may
change at any time during the course of a program.
13
Ramadan, SMK Pekan 2007
LESSON 7
THE DIFFERENCES BETWEEN ETHICS AND LAW
14
Ramadan, SMK Pekan 2007
15
Ramadan, SMK Pekan 2007
LESSON 8
RIGHTS DATA TYPES
DATA EXAMPLES
FOR DIFFERENT DATA TYPES
Integer
Integer data type contains any whole number value that does not have any
fractional part.
16
Ramadan, SMK Pekan 2007
Double
Any number value that may and could contain a fractional part.
String
Any value that contains a sequence of characters.
Boolean
Boolean type consists either a True or False value. Programmers usually use
it to store status.
17
Ramadan, SMK Pekan 2007
This is how we declare a boolean type constant in Visual Basic statement.
LESSON 9
MATHEMATICAL AND LOGICAL OPERATORS
18
Ramadan, SMK Pekan 2007
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.
19
Ramadan, SMK Pekan 2007
20
Ramadan, SMK Pekan 2007
They return an element of logical 1 (True) where the relation is true, and
element of logical 0 (False) where the relation is false.
The diagram shows some common relational operators and their expression.
21
Ramadan, SMK Pekan 2007
22
Ramadan, SMK Pekan 2007
AND operator
Else it is false ( 0 )
OR operator
Else it is false ( 0 )
NOT operator
23
Ramadan, SMK Pekan 2007
Function :
24
Ramadan, SMK Pekan 2007
Symbols :
These operators have their own symbols based on the programming
language.
EQUALITY OPERATORS
The equality determine an operand equal to or
not equal to another operand.
LESSON 10
PSEUDO CODES
25
Ramadan, SMK Pekan 2007
There are no set rules for writing pseudo code.
He or she must use consistent language and syntax in the pseudo code, so
that he or she can understand it at a later stage.
26
Ramadan, SMK Pekan 2007
Each example below demonstrates one of the control structures used in
algorithms : sequential operations, conditional operations, and
iterative operations.
Example:
Computing discount:
Pseudo-code:
Computing the final price of an item
after figuring in discount.
input (request),
output (print)
LESSON 11
FLOW CHART
27
Ramadan, SMK Pekan 2007
Terminator shows the beginning or end of a program.
Input or output shows either an input operation (e.g. an INPUT from the
user) or an output operation (e.g. PRINT some messages).
Example:
LESSON 12
CONTROL STRUCTURES
28
Ramadan, SMK Pekan 2007
SEQUENCE CONTROL
Sequence control refers to the linear execution of codes within a program. In
sequence control, the statements are executed one by one in consecutive
order.
29
Ramadan, SMK Pekan 2007
Let’s see another example of pseudo code that has sequence control
structure.
EXAMPLE
SELECTION CONTROL
30
Ramadan, SMK Pekan 2007
There are times when you want your program to make a decision based on
the situation given.
Let's see the flow chart for a similar selection control example.
31
Ramadan, SMK Pekan 2007
If the service hours are lower than 30 then the program will print a message,
“Please continue to serve in the library”.
32
Ramadan, SMK Pekan 2007
DIFFERENTIATE BETWEEN SELECTION CONTROL
AND SEQUENCE CONTROL
EXT : REPETITION
CONTROL STRUCTURES
Let’s learn about the last control
structure which is repetition control
structure. A repetition control
structure allows the programmer to
specify an
action to be repeated while some
condition remains true.
This program segment will continue its looping until the condition of variable
33
Ramadan, SMK Pekan 2007
named product is greater than 3000.
34