Download presentation
Presentation is loading. Please wait.
Published byYulia Gunawan Modified over 6 years ago
1
CHAPTER 2 & 3: Pseudocode and Developing and Algorithm
2
Objectives Introduce common words & meaningful names
Define basic control structures in Structure Theorem Develop an algorithm
3
Computer Operations Receive information Output information
Perform Arithmetic Assign a value Compare variables Repeat actions
4
Receive information Read and Get
Read: receive input from a record on a file Get: receive input from keyboard Example: Read studentName Get systemDate
5
Output Information Print, Write, Put, Output, Display Examples:
Print: output to printer Write: written to a file Put, Output or Display: output to screen Examples: Write customer name to master file Display ‘Total Number’
6
Arithmetic Add, Subtract, Multiply, Compute etc Examples:
Add number to total Total= Total + number Compute C = (F-32)*5/9 Order of operations is very important
7
Assign a value 3 instances of assigning a value:
Initialize: Initialise or Set Result of processing: ‘=‘ or ‘’ Store a value: Save or Store Examples: Initialise total_price to zero total_price= cost_price + sales_tax
8
Compare Compare 2 variables & select one of the two alternative actions. IF, THEN, ELSE Example: IF student_status is part_time THEN add 1 to part_time_count ELSE add 1 to full_time_count ENDIF
9
Repeat actions Sequence of processing that need to be repeated
DOWHILE, ENDDO Example: DOWHILE student_count <5 Read Student record Print student name, address to report add 1 to student_total ENDDO
10
Meaningful names Name should describe the type of data in the variable
More than one word, use: Camel casing Underscore
11
Structure Theorem Any computer program can be written using 3 basic control structures: Sequence Selection Repetition
12
Sequence Straightforward execution of one step after another Example:
Statement 1 Statement 2 Statement 3 Receive, output, arithmetic & assign values
13
Selection Presentation of a condition and choice between 2 actions, depending on TRUE or FALSE Example: IF condition 1 is true THEN statement(s) in true case ELSE statement(s) in false case ENDIF
14
Repetition Presentation of a set of instructions to be performed repeatedly as long as the condition is true. Example: DOWHILE condition 1 is true statement block ENDDO
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.