Programming
Programming
Programming
C++
CHAPTER 1
INTRODUCTION TO
COMPUTER PROGRAM
Learning Outcome
At the end of this chapter, you should be able to:
•Understand the concepts and importance of programs
and programming.
•Differentiate between program, compiler, interpreter
and assembler.
•Apply the steps in the program development life cycle.
INTRODUCTION
• electronic programmable computers using vacuum tubes and transistors have been created.
1940s
• The first personal computer with a graphical user interface was introduced
1983
Language
Basic of PDLC
Operation
Computer
Basic operation of a Computer
Hardware Software
Computer Component
Language of a Computer
• Computers can only understand machine language.
• Machine language is also called binary numbers or
binary code, which is a sequence of 0s and 1s.
• The digits 0 and 1 are called binary digits or bits.
• A sequence of 8 bits is called a byte.
Language of a Computer
Types and Levels of
Programming Languages
• Example:
To calculate the BMI of a user given the formula:
weight (kg)
BMI =
height (m) x height(m)
Language of a Computer
High-level Language
PROGRAM
Line by line instructions (coding statements) for a computer to
perform specific task.
Accura
cy
Usabili Reliabili
ty ty
Readab Efficiency
ility
Maintain
ability
Language of a Computer
Writing a GOOD program
Include
comment
where
necessary
Use of loop
statement
Use Divide by when
Mnemonic process; necessary
variable name 1) input,
2) output,
3) process
Program Development life cycle
• The process of developing a program is called
program development.
• The process associated with creating successful
application programs is called the Program
Development Life Cycle (PDLC).
Program Development
Life Cycle
Phase1: Analysis
Why
Program Development
Life Cycle
Phase2: Design
CONTROL
STRUCTURE
Iteration/
Sequential Selection
Repetition
condition?
Program Development
Life Cycle
Phase2: Design- Pseudocode
Pseudocode:
• A semiformal, English-like language with a limited vocabulary
used to design and describe algorithms.
• Every statement in pseudocode involves keywords which define
the process and operands.
• Each pseudocode statement should be written in a separate line.
• All statements showing "dependency" are to be indented. These
include while, do, for, if, switch.
Program Development
Life Cycle
Phase2: Design- Pseudocode
Program Development
Life Cycle
Phase2: Design- Pseudocode
BEGIN
Iteration
Sequence structure
structure
Selection
structure
END
Program Development
Life Cycle
Phase2: Design- Flowchart
Flowchart:
• A diagrammatic representation of an algorithm. It explains the
flow of the program.
• Best describes structure of the program: sequence; selection and
iteration.
• Uses geometric symbols where different symbols are used to
represent different actions such as start/stop, decision,
input/output, processing and looping.
Program Development
Life Cycle
Phase2: Design- Flowchart
False
Condition
True
Program Development
Life Cycle
Phase2: Design- Flowchart
Flow of the
program is in
sequence
Program Development
Life Cycle
Phase2: Design- Flowchart
Control
decision of the
program
Flow if
TRUE
Flow if
FALSE
Program Development
Life Cycle
Phase2: Design- Flowchart
FALSE
TRUE
Loop when
TRUE
Proceed when
FALSE
Program Development
Life Cycle
Phase3: Implementation
• The pseudocode and flow chart which have been done in the design
step (phase 2) will be converted into a program by using certain high-
level of programming languages such as BASIC, JAVA, C or C++.
• This step solves the problem by enabling the user to start writing the
programs.
• Coding is the actual process of creating a program in a programming
language.
• The coded program is referred to as source code.
– Must follow certain rules which are called syntax.
– Must then be saved as a program which has the extension ‘.cpp’.
• To be executed, the program is converted by the computer into object
code using a special program called translator such as a compiler or
interpreter.
Program Development
Life Cycle
Phase4: Testing/ Debugging