3. LO1: Select the Program Design Approach
LO2: Document the program logic or design
LO3: Validate the Design
UC : Design A Database 3
4. 1.1 Obtaining Design Documentation and
Requirement for the Program Clarification
1.1.1Pseudo code
Pseudocode is an informal high-level
description of the operating principle of a
computer program or other algorithm.
UC : Design A Database
4
5. Pseudocode
English-like representation of a program
It could be viewed as the outline of a program
It can’t be compiled or executed.
The focus is on solving the problem, not
worrying about the specifics of a
programming Language.
UC : Design A Database 5
6. It uses the structural conventions of a
programming language, but is intended for
human reading rather than machine reading.
Pseudocode typically omits details that are not
essential for human understanding of the
algorithm, such as variable declarations,
system-specific code and some subroutines.
UC : Design A Database 6
7. The programming language is augmented with
natural language description details, where
convenient, or with compact mathematical
notation.
The purpose of using pseudocode is that it is
easier for people to understand than conventional
programming language code, and that it is an
efficient and environment-independent
description of the key principles of an algorithm.
UC : Design A Database 7
8. It is commonly used in textbooks and scientific
publications that are documenting various
algorithms, and also in planning of computer
program development, for sketching out the
structure of the program before the actual coding
takes place
UC : Design A Database 8
9. When we write programs, we assume that the
computer executes the program starting at the
beginning and working its way to the end. We call
this sequence
SEQUENCE is a linear progression where one
task is performed sequentially after another.
In pseudo code it look like this
UC : Design A Database 9
10. Statement 1;
Statement 2;
Statement 3;
Statement 4;
Statement 5 ;
Example, for making a cup of tea:
Organize everything together;
Plug in kettle;
Put teabag in cup;
Put water into kettle;
Wait for bottle to boil;
Add water to cup;
Remove teabag with spoon/fork/;
Add milk and /or sugar;
Serve;
UC : Design A Database 10
11. What if we need to tell the computer to keep
doing something until some condition occurs?
Let’s say we wish to indicate that you need to
keep filling the kettle with water until it is full.
We call this a loop.
WHILE is a loop (repetition) with a simple
conditional test at its beginning Or, in general
UC : Design A Database 11
12. While (<condition>)
Do <Statements>;
Endwhile;
As we could state this as:
While (Kettle is not
full)
Do keep filling Kettle;
EndWhile;
Example, above:
Organize everything together;
Plug in kettle;
Put teabag in cup;
While (Kettle is not full)
Do keep filling Kettle;
EndWhile;
Wait for bottle to boil;
Add water to cup;
Remove teabag with spoon/fork/;
Add milk and /or sugar;
Serve;
UC : Design A Database 12
13. What if we want to make a choice, for example,
do we want add sugar or not to the tea? We call
this selection.
IF-THEN-ELSE is a decision (selection) in
which a choice is made between two alternative
courses of action.
UC : Design A Database 13
15. A flow chart is a graphical or symbolic
representation of a process.
Each step in the process is represented by a
different symbol and contains a short
description of the process step.
The flow chart symbols are linked together with
arrows showing the process flow direction.
UC : Design A Database 15
16. • Pictorial representation of a program
• Can be created with pencil and paper,
Microsoft Word, PowerPoint, Visio (a copy
of this is in the back of the Farrell book), etc.
• For this class, all flowcharts must be done in
Visio
UC : Design A Database 16
22. 1) Sequence:
These is the types of control structure in
which program flows from top to bottom
sequentially without changing the flow of
program execution.
None of the program statements are
skipped or repeated. Every statements are
executed one after another.
UC : Design A Database 22
23. #include
int main ( )
{
int a=5,b=3,c;
c=a+b;
printf(“Value is
%d”, c);
return 0;
}
UC : Design A Database 23
Here, in this above
program example, every
statements are executed
line by line from top left
to right bottom.
None of the statements
are skipped and repeated.
25. A program is required to read three numbers, add
them together and print their total.
Pseudo code
Add_three_numbers
Read number1, number2, number3
Total = number1 + number2 + number3
Print total
END
UC : Design A Database 25
29. The following flow
chart example
presents a very simple
flow chart for the
process of getting out
of bed in the morning.
UC : Design A Database 29
30. UC : Design A Database 30
A program is required to prompt the terminal
operator for the maximum and minimum
temperature readings on a particular day,
accept those readings as integers, and calculate
and display to the screen the average
temperature, calculated by (maximum
temperature + minimum temperature)/2.
32. Pseudo code
Find average_temperature
Prompt operator for max_temp, min_temp
Get max_temp, min_temp
Avg_temp= (max_Temp + min_temp)/2
Output avg_temp to the screen
END
UC : Design A Database 32