Pseudocode Notes

Only available on StudyMode
  • Download(s) : 75
  • Published : January 11, 2013
Open Document
Text Preview
Pseudocode building blocks
http://youtu.be/Xg6alMKCQXU – part 1
http://youtu.be/NaFrBLgRyWY – part 2
- Reading material pseudocode does not match up with answer key. - Pseudocode can more closely model real world languages as is shown below. Sequential Commands
[Module Name] Module
- Keyword
- Must have an End Tag
- Must be one word
Example:
Main Module

End Main Module

Declare [DataVariableName] As [DataType]
- DataVariableName can be any name chosen as long as it is one word - DataType can be one of the following basic types: Float, Real, Integer (real & integer are numbers), String

Example:
Declare NumSandwiches As Integer
Declare FirstName As String

Display (or Write) [String or data variable to be displayed] - If string is used, you must have it start and end with quotations Example 1:
Display “Hello world”
Example 2:
Declare FirstName As String
FirstName = “Jack”
Display FirstName
Example 3:
Declare FirstName As String
NumBurgers = 2
Display NumBurgers
Display “The number of burgers is: “ & NumBurgers

Call [ModuleName] Module
- ModuleName must be a valid module declared in the program (needs to be a single word). Example:
Main Module
Call DisplayTest Module
End Main Module
DisplayTest Module
Display “This is a test”
End DisplayTest Module

Input [VariableName]
- VariableName must be a valid variable declared in Main or the local module. Example:
Main Module
Declare NumBurgers As Interger
Display “Please enter the number of burgers: “
Input NumBurgers
Display “The number of burgers you entered is “ & NumBurgers
End Main Module

Set [variableName]
- Worthless pseudocode command that is not necessary and is not used by most real world languages. (Use = instead) Example 1:
Set NumBurgers = 10
Example 2:
NumBurgers = 10

Conditional / Selection Control Structures

If [conditional statement] Then
- Must have an End tag
- Else logic is optional
- Conditional...
tracking img