Mission:: Program Development Life Cycle (PDLC) Problem Solving Concepts (Part 2)
Mission:: Program Development Life Cycle (PDLC) Problem Solving Concepts (Part 2)
Lab03
Program Development Life Cycle (PDLC)
Problem Solving Concepts (Part 2)
Mission:
1. Experience PDLC by solving problems algorithmically using flowcharts.
Overview
Last week, we have solved many problems using flowchart, but without much emphasis on
the Repetition structure. This week, we put more emphasis on problems that require the
Repetition structure to solve.
Problems
We assume that the programs will be run on a machine as specified in the previous lab,
whereby the machine can only perform a limited set of instructions in some flowchart
symbols, as indicated below:
Rectangle symbol:
1. Assignment only :
2. Assignment with Unary operation :
3. Assignment with Binary operation : ,( { })
Diamond symbol:
1. Logical operations : ,( { })
The word INPUT and OUTPUT may be replaced with any relevant but unambiguous words
(e.g. GET or ACCEPT for INPUT, SHOW or DISPLAY for OUTPUT)
KWBAN (William) 1
Trimester 1, 2019/20 PSP0101 - Problem Solving and Program Design
Question 1
Design a program that accepts two positive integers B and E, calculates B power of E using
repetition, and outputs the result.
Question 2
Design a program that accepts a positive integer N and compute the sum of all the numbers
below N and above 0.
e.g. Given 5, output: 10 (since 4+3+2+1 = 10)
Given 9, output: 36 (since 8+7+6+5+4+3+2+1 = 36)
[ TAKE HOME EXERCISE: Question 2 can be solved without using Repetition structure. Do you know
how? ]
Question 3
Modify your program in Question 2 such that it computes (N-1)!, the factorial of N – 1.
Question 4
Design a program that accepts a positive integer N. Then, the program shows a sequence
formed with | |, where .
Question 5
Design a program that accepts a positive integer N. Then, the program accepts N number of
quiz marks in real numbers, and outputs the average of these quiz marks.
Question 6
Design a program that accepts ten numbers and show the largest number among them.
KWBAN (William) 2
Trimester 1, 2019/20 PSP0101 - Problem Solving and Program Design
Question 7
Design a program that accepts two positive integers A and B, and shows a sequence from A
to B, inclusive of A and B.
Question 8
Design a program that accepts a non-zero positive integer N. If N is an ODD integer, the
program outputs a sequence of alternating 0s and 1s that starts from 1. Otherwise, the
program outputs a sequence of alternating 0s and 1s that starts from 0. In either case, the
length of the sequence must be N.
Hint: Let be .
Perform updates to
Perform again changes back to
KWBAN (William) 3