Presentation is loading. Please wait.

Presentation is loading. Please wait.

Pseudocode. Algorithm A procedure for solving a problem in terms of the actions to be executed and the order in which those actions are to be executed.

Similar presentations


Presentation on theme: "Pseudocode. Algorithm A procedure for solving a problem in terms of the actions to be executed and the order in which those actions are to be executed."— Presentation transcript:

1 Pseudocode

2 Algorithm A procedure for solving a problem in terms of the actions to be executed and the order in which those actions are to be executed. It is merely the sequence of steps taken to solve a problem The steps are normally  Sequence  Selection  Iteration (Repetition)

3 Pseudocode A kind of structured English terminology for describing algorithms. Allows the designer to focus on the logic of the algorithm without being distracted by details of language syntax.

4 Rules for Pseudocode 1. Write only one statement per line  each statement should express just one action for the computer 2. Capitalize initial keyword  READ, WRITE, IF, ELSE, ENDIF, WHILE, ENDWHILE, REPEAT, UNTIL 3. Indent to show hierarchy  Sequence: keep statements that are stacked in sequence all starting in the same column  Selection: indent the statements that fall inside the selection structure, but not the keywords that form the selection  Looping: indent the statements that fall inside the loop, but not the keywords that form the loop

5 Rules for Pseudocode 4. End multiline structures: For example, The “EndIF” is always inline with the “IF” that began the multiline structure. 5. Keep statements language independent  The vocabulary should be the vocabulary of the problem domain, not of the implementation domain.

6 The Structure Theorem It’s possible to write any computer program by using only three (3) basic control structures  Sequence  Selection  Repetition (Iteration)

7 Sequence Execution of one step after another This is represented as a sequence of pseudocode statements Example: Read three numbers Add three numbers Display total of three numbers

8 Selection Presentation of a condition, for example, the choice between two actions, with the choice depending on whether the condition is true or false This represents the decision making abilities of the computer to compare two pieces of information and select one of two alternative actions. In pseudocode, selection is represented by the keywords IF, THEN, ELSE, and ENDIF

9 SELECTION IF condition p is true THEN statement(s) in true case ELSE statement(s) in false case ENDIF *********************************** IF student is part_time THEN Add one to part_time_count ELSE Add one to full_time_count ENDIF

10 REPETITION Presentation of a set of instructions to be performed repeatedly, as long as a condition is true. WHILE condition p is true Statement(s) to execute ENDWHILE

11 REPETITION Set student_total to 0 WHILE student_total<50 Read student record Print student name and address Add 1 to student_total ENDWHILE

12 Monopoly Pseudocode

13 Monopoly Pseudocode/Flowchart http://www.wiley.com/college/busin/icmis/oakman/o utline/chap05/misc/monopoly.htm


Download ppt "Pseudocode. Algorithm A procedure for solving a problem in terms of the actions to be executed and the order in which those actions are to be executed."

Similar presentations


Ads by Google