Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture Notes 8/24/04 (part 2)

Similar presentations


Presentation on theme: "Lecture Notes 8/24/04 (part 2)"— Presentation transcript:

1 Lecture Notes 8/24/04 (part 2)

2 Pseudocode (review) Pseudocode standard which we will follow in this class: - Statements are written in simple English; - Each instruction is written on a separate line; - Each set of instructions is written from top to bottom, with only one entry and one exit; - Groups of statements may be formed into modules, and that group given a name.

3 How to Write Pseudocode
6 basic computer operations: receive information put out information perform arithmetic assign a value to a variable or memory location compare two variables and select one of two alternative actions repeat a group of actions

4 Receive Information A computer generally gets information in one of the following ways: From a file Pseudocode -> “Read” From a keyboard Pseudocode -> “Get”

5 Receive Information Examples: Get file name
Read first line from the file Get number of students Read the names of the students from the file

6 Put Out Information A computer generally outputs information in one of the three ways: Print on a printer “Print” Write to a file “Write” Display on a monitor “Display”

7 Put Out Information Examples: Print “Hello everyone!”
Write “My first homework” to hw_1.txt Display average_age

8 Perform Arithmetic Either actual mathematical symbols or words can be used: Multiply Length by Width to compute Area Area = Length * Width

9 Perform Arithmetic Symbols that will be used in this class:
Addition Subtraction - Division / Multiplication * Modulus % Parentheses () Also can use the words : Compute and Calculate

10 Example Write the pseudocode for calculating the average age of the students in our class. Prompt the user for number of students Get number of students Prompt for all of the ages Get the ages of all students Add all ages together to obtain Total_Age Divide Total_Age by the number of students Display the result


Download ppt "Lecture Notes 8/24/04 (part 2)"

Similar presentations


Ads by Google