Pseudocode Building Blocks

Only available on StudyMode
  • Topic: For loop, Statement, Imperative programming
  • Pages : 4 (475 words )
  • Download(s) : 194
  • Published : July 13, 2012
Open Document
Text Preview
Pseudocode Building Blocks
* Reading Material pseudocode does not match up with answer key. * Pseudocode can more closely model real world languages as shown below.

Sequential Commands
* Refer to reading material in chapter 2 pages 33-37.

[ModuleName] Module
* Keyword
* Must have an End Tag
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, String. Example:
Declare NumSandwiches As Integer
Declare FirstName As String
Display (or Write) [Sting or data variable to be displayed]
* If sting 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 NumBurgers As Integer
NumBurgers = 2
Display NumBurgers
Display “The Number of Burgers is:” & NumBurgers
Call [ModuleName] Module
* ModuleName must be a valid module declared in the program 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
Declared NumBurgers As Integer
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 Example 1:
Set NumBurgers = 10
Example 2:
NumBurgers = 10 (does the same thing)
Conditional / Selection Control Structures
* Refer to Chapter 3 pages 62-71
If [conditional statement] Then
* Must have an End tag
* Else logic is optional
* Conditional statement must use a relational operator
* Valid...
tracking img