Professional Documents
Culture Documents
Chapter 1 Intro HF
Chapter 1 Intro HF
Chapter 1 Intro HF
Introduction to Computer
Programs
Objectives
To introduce the elements of a computer
program
To explain the importance of programming
To describe good programming styles
To explain the relationships between
compilers, interpreters and programs
Contents
Basic Concept
Program Development Process
Program Control Structure
Introduction to computer
o Hardware
o Device that processes data to create information (ex:
input, output, storage and processing devices)
o Software
o Step-by-step instructions that tell the computer how to do
its work.
o It is also called a program.
o It’s purpose to convert data to useful information
Elements of a computer program (Cont…)
SOFTWARE
SYSTEM SOFTWARE
• provides an environment for user
to execute the application software. APPLICATION SOFTWARE
•Enables the application software
to interact with computer • end user software.
hardware. •A program that performs a
•Eg. Operating System common task to the user.
•Eg. Word, Excel.
Elements of a computer program (Cont…)
Computer Program
Computer program
Hanly [2001], “List of instructions that direct the
computer to transform information from one
form to another.”
Information refers to the contains of specific
memory location.
It is written using programming language.
Computer program
Turn data (input) into useful information
(output).
Program uses variables to store data
Storage
STORAGE
•Store the data or information for
future use (permanently or
INPUT temporarily)
•E.g. Hard disk, memory
•Whatever data that is PROCESSING
inserted into a computer
using input devices •Convert input data into
•E.g. Mouse, keyboard information.
•E.g. CPU OUTPUT
•Generate the useful
information using output
devices
•E.g. Monitor, printer
The Importance of Programming
Reliability of Output
Good program should produce correct output
During 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 is produces no errors during execution
process
Program must achieve its purpose so that the final result
can be trusted
Use of pseudocode or flowchart to outline the program
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 user 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
The Importance of Good Programs
(Cont…)
o Spacing
Each instruction begins with new line
o Indent
Each instruction has indention depends on its
structure
Makes the structure of the program clearer and
easy to read
A statement within a statement should be
indented to show the user which statement is
subordinate of the other
The Importance of Good Programs
(Cont…)
Comments
Help a human reader to understand the
program
Can be placed anywhere within a program
Will not be executed by compiler
C++ supports two types of comments
Line Comment
Block Comment
The Importance of Good Programs
(Cont…)
Comments (Cont…)
Line comment
Begin with two slashes (//)
Ex: //This is Line comment
Block Comment
Begin with the symbol /* and end with the symbol */
Use for statements that span across two or more
lines
Ex: /* This program calculates the salary of
employees */
Program Errors
Example
1 cout << “/n There are five syntax errors”
2 cot >> “Correct Them;
INTERPRETER
ASSEMBLER COMPILER
• a program that • a program that translates • a program that translates
translates the assembly high-level language into source code of high-level
language program into machine language. language into machine
machine language. •Translate the source code language.
once and saves to be reused. •Each instruction is
•Requires less memory and interpreted into machine
runs faster. language.
•Eg. PASCAL, C++, COBOL •Program is easier to develop.
•Eg. BASIC.
Basic Concept
Compilation Process
(Input) (Output)