Chapter 1-a FLOW CHART
BACKGROUND Program : composed by 1 programmer composed by 1 team of programmers Required planning & design using: FlowChart: “Symbols representing the flow of control steps of a program’s execution” Objective: to simplify program-code composition “FLOW CHART”
SYMBOLS IN FLOW CHART n y Symbol for presenting data/input or results/output Symbol of a process or program statement Symbol for conditional statement where decision is based of whether the condition is true or false y n Process flow/direction Symbol for result’s documentation (in hard copy) Start and End of a program indication Symbol for reading data/input using punched cards. Connector
TYPES OF INSTRUCTION Process A Process B Process C A. Unconditional Statements Process A Process B Process C
TYPES OF INSTRUCTION Condition Process A Process B False True B. Conditional Statement Condition False True Process A Process B
TYPES OF INSTRUCTION Condition Process A Process B False True C. Looping Statements Condition False True Process A Process B
Queue for buying coupon EXAMPLE: 1. Flow chart for buying cakes using coupons: Start Prepare Money Queue for buying coupon Buy the Coupon A Choose Cake Trade cake for coupon Stop A
EXAMPLE: 2. Flow Chart for Study: A B Start Do the Questions Prepare Equipments Match with Answers Read Notes Fit? no Understand Notes yes Understand Contents Take a break Stop A B
EXAMPLE: 3. Find the average of 3 input data numbers: Start Read: A,B,C X = A+B+C 3 Write: X Stop
PRACTICE QUESTIONS 1. Given: A number of data The amount of data depends on the number of inputs that may varies. Solve for : The Average of all data 2. IF A is a negative number, add 3 to X IF Not, subtract 3 from X (Do it in Classroom…)
Answer 1: Start TTL = 0, CNT = 0 Read: X yes End of Data No Write: X TTL = TTL / CNT TTL = TTL + X WRITE CNT, TTL CNT = CNT+ 1 Stop
Answer 1: Start TTL = 0, CNT = 0 Read: X yes X = 9999 ? No Write: X TTL = TTL / CNT TTL = TTL + X WRITE CNT, TTL CNT = CNT+ 1 Stop
Answer 2: Start Read: A, X no A 0 ? yes X = X + 3 X = X - 3 Write: X Stop
Latihan Soal Menampilkan bilangan 1 s/ 10 Menentukan apakah data yang dimasukkan adalah bilangan positif atau negatif Menentukan apakah data yang dimasukkan adalah bilangan genap atau ganjil
Latihan soal 4. Tampilkan deret : -11, -9, -7, -5, -3, -1, 0, 2, 4, 6, 8, 10 5. Tampilkan deret : -10, 8, -6, 4, -2, 0, 1, 4, 9, 16, 25 6. Tampilkan deret : 0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55
Soal latihan 1. Buatlah algoritma untuk menghasilkan deret : -10, 8, -6, 4, -2, 0, 1, 3, 6, 10, 15, 21 2. Buatlah algoritma untuk menghasilkan deret : -13, 11, -9, 7, -5, 3, -1, 0, 1, 4, 9, 16, 25, 36, 49 3. Buatlah algoritma untuk menghitung rata-rata, nilai maximum dan minimum dari nilai ujian Pengantar Teknik Komputer