Topic2 Program Development Life Cycle
Topic2 Program Development Life Cycle
PROGRAM DEVELOPMENT
LIFE CYCLE
Prepared for:
CSC 402 – Programming I
COMPUTER SYSTEM
What is a Programming
Language?
Programming Language:
Is used by programmers to write computer programs
It is used to write instructions written by programmer in order to
tell the computer what to do
Most people refer programming language to high level language
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab. Rauf – UiTM Shah Alam
MyProgram.exe
MyProgram.cpp MyProgram.obj
Program is combined with
Program is Program is translated programs from library and is
written in C++ into Machine Language ready for execution
Compiler Linker
Translates source program Link the object program with other
into Machine Language programs from the library
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab. Rauf – UiTM Shah Alam
What is Computer
Programming?
Programming:
Is a process of designing and building and executable computer program
for accomplishing a specific task
Is a process of PROBLEM SOLVING
Before you can write your codes inside the computer,
you NEED TO KNOW HOW TO SOLVE the problem first
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab. Rauf – UiTM Shah Alam
Analysis
Maintenance Design
Testing Implementation
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab. Rauf – UiTM Shah Alam
1. Problem Analysis:
When analyzing a problem, you need to determine:
1. Input:
What kind of data do you need from the user
2. Process:
What do you need to do get your output
3. Output:
What do you want to display to the user
EXAMPLE
2 3 1
Input Process Output
1st number sum = 1st number + 2nd number “The sum of 2 numbers is”,
2nd number sum
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab. Rauf – UiTM Shah Alam
QUICK EXERCISE
QUICK EXERCISE
QUICK EXERCISE
2. Algorithm Design:
What is an ALGORITHM?
Algorithm:
Is a set of sequential instructions that are followed to solve a problem
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab. Rauf – UiTM Shah Alam
1. Read 2 numbers
2. The summation of 2 numbers is calculated by adding up the 1st number and the
2nd number
3. Display the summation of 2 numbers that was calculated
2. Algorithm Design:
Therefore in order to make an algorithm more precise,
there are 2 ways an algorithm can be designed:
1. Pseudocode:
In written form These algorithm design is more precise
because:
2. Flowchart:
Uses limited vocabulary
In a graphical form
Make use of variables
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab. Rauf – UiTM Shah Alam
2. Algorithm Design:
Pseudocode:
Is an algorithm in written form (text-based) by using a human
language
The flow of algorithm should be written in sequence with:
A start
An end
TIP:
The flow of your pseudocode can clearly be seen when you do
numbering for each step
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab. Rauf – UiTM Shah Alam
PSEUDOCODE
PSEUDOCODE CONSTRUCT
Computation/Assignment
Compute var1 as the sum of x and y
Assign expression to var2
Increment counter1
Input/Output
Input: Read var1, var2, …
Output: Display var1, var2, …
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab. Rauf – UiTM Shah Alam
PSEUDOCODE CONSTRUCT
SELECTION
1. One Way Selection
2. IF condition THEN
2.1 statement 1
2.2 etc.
2. Two Way Selection
3. IF condition THEN
3.1 statement 1
3.2 etc.
4. ELSE
4.1 statement 2
4.2 statement 3
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab. Rauf – UiTM Shah Alam
PSEUDOCODE CONSTRUCT
REPEATITION
1. WHILE structure
5.5. WHILE condition (while condition is true, then do
subordinate statements)
5.1 statement 1
5.2 etc.
2. DO – WHILE construct
6. DO
6.1 statement 1
6.2 etc.
7. WHILE condition
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab. Rauf – UiTM Shah Alam
PSEUDOCODE CONSTRUCT
REPEATITION
3. FOR structure
8. FOR bounds on repetition
8.1 statement 1
8.2 etc.
7. WHILE condition
© Najwa Abd Ghafar – UiTM Johor
1. Start
2. Display “Enter the 1st number”
3. Read num1 INPUT
4. Display “Enter the 2nd number”
5. Read num2
6. sum = num1+ num2 PROCESS
7. Display “The sum of 2 numbers is” and sum OUTPUT
8. End
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab. Rauf – UiTM Shah Alam
QUICK EXERCISE
QUICK EXERCISE
QUICK EXERCISE
QUICK EXERCISE
QUICK EXERCISE
Age Description
Less than 10 Not eligible because you’re too young
Between 10 and 49 Eligible to enter
50 or more Not eligible because it might be dangerous
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab. Rauf – UiTM Shah Alam
2. Algorithm Design:
Flowchart:
Is an algorithm in graphical form which is made up of symbols
The flow of algorithm should be written in sequence with:
A start
An end
This algorithm design allow us to see the actual “flow” of the
program
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab. Rauf – UiTM Shah Alam
Input / Output
Process
Decision
Module / Function
Connector
Flow Line
© Najwa Abd Ghafar – UiTM Johor
EXAMPLE
© Rose Hafsah Ab. Rauf – UiTM Shah Alam
Start A
A
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab. Rauf – UiTM Shah Alam
QUICK EXERCISE
QUICK EXERCISE
QUICK EXERCISE
Age Description
Less than 10 Not eligible because you’re too young
Between 10 and 49 Eligible to enter
50 or more Not eligible because it might be dangerous
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab. Rauf – UiTM Shah Alam
QUICK EXERCISE
3. Algorithm Implementation:
Once the algorithm is designed and has been correctly verified, the
algorithm can now be implemented
But HOW?
EXAMPLE
#include <iostream>
using namespace std;
int main()
{
int num1, num2, sum
Compiling:
Once you have finished writing your codes, you can try and run your
program
But WHAT DO YOU NEED to run your program?
COMPILER:
Will ensures that your program follows the constructs of the language
(a.k.a NO SYNTAX ERROR!!)
When there are no syntax error, it will then translate the program into
machine code
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab. Rauf – UiTM Shah Alam
4. Program Testing:
Your program should be tested with all types of data and cases
so that you can find and eliminate errors
Errors is also known as bugs
The process of removing bugs is called debugging
© Najwa Abd Ghafar – UiTM Johor
© Rose Hafsah Ab. Rauf – UiTM Shah Alam
QUICK EXERCISE
5. Program Maintenance:
Involves you modifying or upgrading the existing program or system
It is important to document your program so that you and other
programmers can make changes or updates later
There are 3 types of documentation:
1. Documentation in the Program:
Comments can be used to explain certain codes
2. Documentation outside the Program:
Diagrams, flowcharts or descriptions can be used to explain how
the programming problem was solved
3. Documentation for the User:
User documentation or user manual is used to explain the
functions of the program