3/27/2022
FUNDAMENTAL OF
COMPUTER
PROGRAMMING
Week 1
TOPIC 1
Prepared By
Sr Dr. KHAIRULAZHAR BIN ZAINUDDIN
Course Description
This course introduces students to the basic
computer programming language. Students
are expected to solve Geomatics tasks using
programming procedures.
2 credit unit
• 1h lecture
• 2h lab exercise
80 hours student learning time
1
3/27/2022
Learning Outcomes
Student should be able to:
1. Explain the theoretical concept and procedures
for a simple programming/coding (C2)
2. Relate the basic computer programming
techniques in writing a small/simple and
executable program (P1)
3. Describe in writing a program knowledge and
skills to solve a selected Geomatics issue (P1)
Teaching Method & Topics
Lecture Laboratory
Introduction (2h) Introduction to C++ structure (8)
Basic Elements of Computer Program (4h) Control Structure & Statement (16)
Control Structure & Statement (6h) Input File and Output File (4h)
Input and Output File Stream (2h)
2
3/27/2022
Student Learning Time
Lecture 1h, Lab exercise 2h
Student Preparation Time/week:
• 1h for lecture
• 2h for lab
• *Make sure be prepared before entering the
class and lab session!
Assessment
100% Course Work
Written Test (CLO1, C2) : Lab Test (CLO2, P1) : Group Project (CLO3,
40% 10% P1) : 50%
Individual Individual Week 12 - 15
Test on Topic 1 and 2 Lab Test 1 : 10%
Week 6 Week 14
3
3/27/2022
Academic Session 20222
Teaching Period 14 weeks
Session 20222: 28/03 – 17/07/2022
• Mid Sem Break: 1 – 8 May 2022
• Special Holidays: 30/5 – 5/6/2022
Week 1 Topic 1
Lesson content:
1. Introduction to computer programming
2. Components of the computer program
4
3/27/2022
Introduction to
computer programming
• WHAT IS A COMPUTER PROGRAM?
– Sequences of instructions and
decisions that the computer carries
out to achieve a task.
Input Process Output
Software
Apps
Hardware driver
Introduction to
Computer
The computer is an electronic device that
accepts input, processes data, storing data
and generates the output
10
5
3/27/2022
Categories of
Computers
• Mainframe computers
• Midsize computers
• Micro computers (personal
computers)
11
A Brief Overview
of the History of
the Computers
• Early computer-like machines
– Mark I
– ENIAC
– Von Neumann architecture
– Univac
– Transistors and microprocessors
12
6
3/27/2022
Basic components of a computer
systems
Hardware
• Device that processes data to create information (ex:
input, output, storage and processing devices)
Software
• Step-by-step instructions that tell the computer how
to do its work.
• It is also called a program.
• Its purpose is to convert data to useful information
13
Two types of program
System program
• To control the computer
• Operating system (Windows, macOS, Linux)
Application program
• To perform a specific task
• Word processor, spreadsheet, presentation
• Games, CAD,
14
7
3/27/2022
Component of Computer Program
• Program is a set of instructions that the computer
needs to follow to process the data into information.
– Without software, the computer are useless
• Programming Language contains a set of instructions,
data and rules that are used to construct a program.
Ex: C++, C, VB, python, java…
• Programming is the act of designing/writing and
implementing computer programs using the
programming languages.
• Programmer is a person who writes a computer
program.
15
Computer Program
• Computer is a machine – thus only
understand the machine language.
• Machine language is a low-level language
comprised of binary numbers
1011010000000101
• Computer (and all digital devices) only
recognizes the binary data
16
8
3/27/2022
To write a program for a computer we
must use a computer language – like
humans communicate to each other
Human-to-human: English, Malay,
Mandarin, Tamil, Arabic, Urdu….
Computer
Program Computer only understands machine
language
Human-to-computer?
17
A Brief Overview of the History of the
Programming Language
• Over the years computer languages have
evolved from machine language to natural
language
1940s 1950s 1960s 1970s 1980s 1990s
18
9
3/27/2022
• Machine language instructions are in binary numbers,
e.g. 1011010000000101 – low-level language.
• Symbolic languages simply mirrored the machine
languages using symbols, or mnemonics, to represent
the various machine language instructions
entry main, ^m<r2>
19
• A special program called an assembler is used to
translate symbolic code into machine language
• Because symbolic languages had to be assembled into
machine language, they soon become known as
assembly language
• The desire to improve programmer efficiency and to
change the focus from computer to the problem being
solved led to the development of high-level languages
20
10
3/27/2022
• Ideally, we could use our natural language (such as
English, French, or Chinese), and the computer
would understand it and execute our request
immediately
• Although this may sound like something out of
science fiction, considerable work on natural
language is being done in labs today.
21
Five generations of programming language
1st Generation – Machine language
• Basic language of the computer, representing
data as 1s and 0s.
2nd Generation – assembly language
• Low-level programming language.
• Allows programmer to write a program using
abbreviations or more easily remembered
words instead of number.
22
11
3/27/2022
Five generations of programming language
High-level language
• 3rd Generation – Procedural languages
• 4th Generation - Problem-oriented language
– Fortran, COBOL, Pascal.
5th Generation
• Natural languages.
• Use human language to give people a more natural
connection with the computer.
23
Example of programming language
24
12
3/27/2022
Interpreters and Compilers
• A program in the form of a high-level language
is called source code.
• The source code must be translated into
machine language (binary code) since this is
the only language that the computer
understand.
• The machine language is known as object
code.
25
Interpreters and Compilers
• An interpreter is a program that translates the source
code into machine language.
• Every time the program is run, the interpreters must
once again translate each instruction.
• Compiler is another program that translates the
source code into machine language.
• The compiler makes the translation once and saves
the machine language so that the instructions do not
have to be translated each time the program is run.
26
13
3/27/2022
Source Code, Object Code and
Executable Code
• When a program is compiled, the compiler generates
the object code, which is saved in a file with the file
extension *.obj.
• However, the object code is incomplete. A program
called a linker is used to create an executable program.
• Linker combines the object code with machine
language codes necessary to run a program, called
executable code.
• Executable code is saved in a file with file extension
*.exe.
27
Compilation Process of Computer Program
Using C++ Editor to produce the SOURCE CODE
source code
Using C++ Compiler to compile COMPILER
the source code
The compiled process produces OBJECT CODE
object code
Link the object code with LINKER LIBRARY
additional codes
Produce result EXECUTABLE
CODE
28
14
3/27/2022
Easy to express tasks from a particular
problem domain.
The Allow user to instruct computer to do a
specific task in a certain instances.
Importance
of Computer A skill required for a computer scientist
Programming and software engineer.
Geomatician = solve big data for analysis
A skill required to create a successful
computer program.
29
The Importance of Good
Programs
• Reliability of Output
– Good program should produce correct output
– During the testing phase different set of input data is used to
ensure the reliability of output
• Program’s Efficiency
– Good program should be reliable and efficient in the sense
that it produces no errors during the execution process
– Program must achieve its purpose so that the result can be
trusted
– Use of pseudocode or flowchart to outline the program
30
15
3/27/2022
The Importance of Good
Programs (..cont.)
• Interactivity
– Interaction between user and the program is well defined
– Interactivity is important so that the user knows the
processing status
– User-friendly programs allow users to respond to the
instructions correctly and allow them key in valid input
• Program readability
– Readability is concerned with how other person views one’s
program
– Use of indention and comment increase the level of
readability
31
Wrap up
• Computer is a device to help humans in their
daily lives.
• Computer is driven by a series of instructions
known as a computer program – without the
program computer is useless.
• Humans can write the program using natural
language.
32
16
3/27/2022
Wrap up
• Computer only understand the machine
language; thus, the program need to be
translated into machine language using
compiler.
33
END OF LECTURE
Next lecture: Program Development Life Cycle
34
17