Title: Pseudo code
Course: CPS 120: Introduction to Computer Science ~ Master (Aug/2015) OLD > Section: Learning Units

Characteristics of Pseudo code:

- Is the most common way to show the steps of an algorithm.
- Is an English-like, informal, high-level description of some algorithm.
- Is similar to a programming language but is intended for human reading rather than machine reading.
- Typically omits details that are not essential for human understanding of the algorithm.
- Is often used for sketching out the structure of a program before the actual coding takes place.
- Should document any assumptions made about the algorithm.

Example 1: Get mustard during a television commercial

Assumptions

- Person is on the couch
- Mustard is in the refrigerator

Pseudo code

1. Get off the couch
2. Walk to the refrigerator
3. Scan for the mustard
4. Retrieve the mustard
5. Close the refrigerator
6. Return to the couch

Example 2: Process gas payment at the pump

Assumption

- User has a working credit card

Pseudo code

1. "Listen" for credit card inserted into gas pump
2. Read the ID from the credit card
3. Use the ID to verify the credit card account
4. Signal user to start fill-up
5. “Listen” for end of fill-up
6. Add fill-up amount to the credit card account
7. Print the receipt

Example 3: Multiply two numbers from user

Assumption

- User enters two valid numbers.

Pseudo code

1. Get the first number from the user. Call it X.
2. Get the second number from the user. Call it Y.
3. Multiply the first number by the second number. Store the result in M.
4. Display M.