Lab 1 Week 3: Objective
Lab 1 Week 3: Objective
LAB 1 Week 3
LAB 1 WEEK 3
Objective
1. To describe the steps in the program development process
2. To introduce algorithms and pseudocode
3. To introduce desk checking – manually check the algorithm
Deliverable items
For each of the following activities, you are required to:
1. Determine input, output and process. Provide your assumptions, if any,
2. Develop a complete algorithm, pseudocode, OR flowchart, and
3. Desk checking with some sample data.
Algorithms
Must be written in simple English
Unambiguous, terminating and executable
Step by step and in order
Popular methods for representing algorithms are :
Flowchart Pseudocode
1 Sep 2012
Fundamental Programming
LAB 1 Week 3
Simple Selection
Simple
(IF-THEN-ELSE)
Simple Sequence Repetition
(Loop)
Examples
1. Simple Sequence
Flowchart Pseudocode
1.0 START
7.0 Logout
8.0 END
2. Simple Selection
2 Sep 2012
Fundamental Programming
LAB 1 Week 3
(IF-THEN-ELSE)
Flowchart Pseudocode
1.0 START
7.0 Logout
8.0 END
3. Simple Repetition
Flowchart Pseudocode
1.0 START
2.0 Login to E-learning
2.1 IF password is correct THEN
Go to Step 3.0.
ELSE
Repeat step 2.0.
3.0 Select the course
4.0 Select the topic
5.0 Select the file
5.1 IF download the file THEN
Save File. Go to Step 7.0.
5.2 ELSE. Open File
6.0 Print the notes
7.0 Logout
8.0 END
4. Program with input and output
A student has to take three tests per semester. Each test has maximum marks of
50. By using a system, lecturer can enter a student’s ID and marks obtained for
each test as input. Draw a flowchart and write the pseudocode for the algorithm
3 Sep 2012
Fundamental Programming
LAB 1 Week 3
to calculate the percentage obtained by the student. Print the result along with
his student’s ID.
Flowchart Pseudocode
1.0 START
Start
2.0 Read student ID and Read three marks
(marks1, marks2, marks3).
total = marks1+marks2+marks3.
6.0 END
Desk checking
4 Sep 2012
Fundamental Programming
LAB 1 Week 3
2.0 20 40 50
3.0 110
4.0 73
5.0 73
Second
pass
2.0 10 20 30
3.0 60
4.0 40
5.0 40
Or simplified version :
Activity #1
Write a pseudocode and draw a flowchart to compute the area of a circle. The
formula of the area of a circle is ∏r2 , where r is the radius of the circle. The
program accepts the user input for the radius and displays the result on the
standard output.
Activity #2
Write a pseudocode and draw a flowchart to find the sum of first 5 integer
numbers.
Activity #3
Write an algorithm (pseudocode and flowchart) to solve the following problem: A
bank account starts out with RM10000. Interest is compounded monthly at 6%
per year (0.5% per month). Every month, RM800 is withdrawn to meet college
expenses. After how many years is the account depleted?
Activity #4
Draw a flow chart for a program that will display the following output:
References:
Labsheet materials of Structured Programming & Database lab. class,
CIS Dept., University Technology Petronas.
5 Sep 2012