ICT Form 5 Chapter 1
ICT Form 5 Chapter 1
ICT Form 5 Chapter 1
PROGRAM
A computer program is a series of organised instructions that directs a computer to perform tasks. Without programs, computers are useless. A program is like a recipe. It contains a list of variables (called ingredients) and a list of statements (called directions) that tell the computer
PROGRAMMING
commands or instructions which directs a Later these commands or instructions will be compiled and/or interpreted and then transformed to executable instructions that
PROGRAMMING LANGUAGE
A programming language is a set of words, symbols and codes that enables humans to communicate
with computers.
programs, that direct a computer to perform computation and to organise the flow of control between mechanical devices.
software analyst.
A programmer analyst designs computer programs besides writing them. A computer scientist is a generic or broad term for a professional with
Professional programmers may work in corporate IT departments, software houses and service companies. Sometimes professional programmers work for
consulting companies and their work often takes them to their clients workplace.
A low-level programming language is a programming language that provides little or no abstraction from computers microprocessor. A high-level programming language is a programming language that is more
Machine language statements are written in binary code, and each statement corresponds to one machine action.
An assembly language programmer writes instructions using symbolic instruction codes that are meaningful
abbreviations or mnemonics.
An assembler is a program that translates assembly language into machine language. Since assembly language consist of human-readable abbreviations, the assembler must first convert assembly language into machine-readable language before the computer can readily understand its instructions.
to write instructions.
High-level programming languages make complex programming simpler and easier to read, write and maintain.Programs written in a high-level programming language must be translated into machine language by a
compiler or interpreter.
procedural language, often abbreviated as 4GL, enables users to access data in a database.
A very high-level programming language is often referred to as goal-oriented programming language because it is usually limited to a very specific application and it might use syntax that is never used
YASIR - SMK BATU SEPULUH SQL, NOMAD and FOCUS are examples of fourth generation programming languages.
For example mobile telephones and PDAs. OPL is an interpreted language that is analogous to BASIC. In the early years, before the computer was invented, there are several inventions of counting machines.
In the top-down design model, programs are drawn as rectangles. A topdown design means that the whole program is broken down into smaller sections that are known as modules.A program may have a module or
several modules.
programs which employ a hierarchy of modules. This means that control is passed downwards only through the hierarchy.
Examples of structured programming languages include Ada, Pascal and
Fortran.
OBJECT-ORIENTED PROGRAMMING
The object-oriented approach refers to a special type of programming approach that combines data with functions to create objects.
another.
LESSON 4 TRANSLATOR
Sometimes two people cannot understand each other because they dont
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. The translation of high level languages to machine language is performed by
a translator.
PROGRAM
Have you ever wondered how your computer runs your favourite software?
Your favourite software is a program that consists of several instructions
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. Example of assemblers are MACRO-80 Assembler and Microsoft MASM.
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
COMPILER
The source code (in text format) will be
converted into machine code which is a file consisting of binary machine code
file.
When a user wants to run the program, the object program is loaded into the memory of the computer and the
program instructions begin executing.
A compiled code generally runs faster than programs based on interpreted language. Several programming languages like C++, Pascal and COBOL used compilers as their translators.
as well.
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
Microsoft.
capabilities.
Drag and drop user interface allows you to instantly create an interactive user interface for your software without dozens of codes. Data access features allow your application to access information from a database such as a telephone book program.
ActiveX technologies allow you to make use of the functionality provided by
other applications.
Internet capabilities allow your program to interactively utilise the Internet.
12
1. 2. 3. 4. 5.
Variables
Variable is a data container that stores information. The value inside may change at any time during the course of a program.
13
14
Constant is a virtual data container that stores information. The value will never change (remains constant) at any time during the course of a
Variables is a virtual data container that stores information. The value inside may change at any time during the course of a program.
15
Integer data type contains any whole number value that does not have any
fractional part.
Double
Any number value that may and could contain a fractional part.
String
17
Boolean
Boolean type consists either a True or False value. Programmers usually use it to store status.
18
Operator is a symbol or notation that tells a computer to perform certain An example: the plus (+) notation will tell the computer to perform the
19
20
Mathematical operators are notations that tell the computer to perform mathematical operations.
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
Lets understand a relational operation with the following examples. In this expression, A >= B is
used to test if the value of left expression (A) is greater than or equal to that of the right expression (B). If the conditions are met, then the program will return a logical 1 and proceed to print "A is greater than or equal to B" else it will return a logical 0 and proceed to print "A is less than B".
operations.
Examples of Logical operation are: AND, OR, and NOT. Logical operator compares 2 conditions and returns a TRUE or FALSE value.
22
AND operator
The diagram shows a truth table of AND operator.
Notice that truth value of X AND Y is True ( 1 ) if
OR operator
The diagram shows a truth table of OR operator. Notice that truth value of X OR Y is only True ( 1 ) if either X or Y are True ( 1 ) or both X and Y are true ( 1 ) Else it is false ( 0 )
NOT operator
The diagram shows the truth table of NOT operator NOT X is the negation of X, it is
essentially the 1's complement operation.
Notice that truth value of NOT X is True ( 1 ) when X is False and vice versa.
23
Function :
Logical operators perform logical operations such as checking the condition of two Boolean values.
24
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.
Remember we must use "=" and not "<>" when testing if two primitive values are equal in
grammar.
computer codes because each pseudo code statement can often be converted
into the programming language virtually
line by line.
25
YASIR - SMK BATU SEPULUH There are no set rules for writing pseudo code. A programmer can have his or her personalised pseudo code.
He or she must use consistent language and syntax in the pseudo code, so
In this course we will enforce three standards for good pseudo code Number each instruction. This is to enforce the
notion of an ordered sequence of the operations. Furthermore we introduce a dot notation (e.g. 3.1
come after 3 but before 4) to number subordinate
effectively computable.
Completeness. Nothing is left out.
26
iterative operations.
after figuring in discount. Note the three types of instructions: input (request),
27
Lets identify some of the main elements in the flow chart. We have five
Terminator shows the beginning or end of a program. Flowline and arrowhead use to connect
symbols and indicate the sequences of
operation.
Input or output shows either an input operation (e.g. an INPUT from the user) or an output operation (e.g. PRINT some messages). Process shows a process to be carried out (e.g. calculation). Decision shows a decision (or choice) to be made. The program should continue along one of two routes (e.g. if...else).
A flow chart is a diagram using symbols to show the step-by-step sequence of procedures in a program. A flow chart describes the logic and program
the program. The program will then check whether his marks is more/equal to 50 or not. If the marks are over or equal to 50, the program will print a congratulatory message together with the marks. If the marks are lower than 50 then
the program will print a motivational
28
Control structure can be divided into sequence, selection and repetition control structures.
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.
In sequence control, the statements are executed one by one in consecutive order.
29
YASIR - SMK BATU SEPULUH Lets see an example of pseudo code that has sequence control structure.
This program will request the users date of birth and then request todays date, calculate the age and finally will print the users age. For example, todays date is 1-JAN2006, then the results will be shown as
follows:
Lets see another example of pseudo code that has sequence control structure.
Lets see the flow chart for a general sequence control structure. As we can see, the flow chart for sequence control is very simple.
It will execute statement 1 followed by statement 2 and any
following statements.
30
EXAMPLE
SELECTION CONTROL
There are times when you want your program to make a decision based on the situation given.
For example, a program that stores students
result.
An example of selection control is If...Then...Else statement. The basic pseudo code for If...Then...Else statement is as follows.
Let's see a pseudo code example for the If...Then...Else" statement for a program that will print You are too heavy to ride
the toy car if the students
31
YASIR - SMK BATU SEPULUH Let's see the flow chart for a similar selection control example. Let's see a program that will respond differently for different service hours in a school library. A student requests her service hours in a library from the program, the program will then check whether her service hours are more than/equal to 30 or not. If the service hours are over or message, Thank you for your service.
message, Please continue to serve in the library. Let's write an example of a program that implements sequence control structure. This program will declare a constant pi equal to 3.142. Then the program declares two variables to be used in the program (r and volume). The program will then assign some value to the r variable. The program will then calculate the volume using the formula volume = (4/3)r
The program will then display the volume calculated with a message
box.
32
YASIR - SMK BATU SEPULUH Now write an example program that implements selection control structure. Write a program that will retrieve the current date from the system.
If todays date is more than 15 then the program will display a message box with
33
This program segment will continue its looping until the condition of variable
34