Pseudocode/Gaddis Pseudocode
Appearance
Gaddis Pseudocode refers to the pseudocode language described in the book, "Starting Out with Programming Logic and Design", by Tony Gaddis. The language includes elements for variables, named constants, comments, input / output, operators, conditional statements, loops, subroutines, file processing, and classes.
Variables
[edit | edit source]Data Types:
IntegerRealStringCharacter
Syntax:
Declare DataType VariableNameDeclare DataType ArrayName[Size]
Constants
[edit | edit source]Syntax:
Constant DataType Name = Value
Comments
[edit | edit source]Syntax:
// Comment
Input / Output
[edit | edit source]Syntax:
Input VariableNameDisplay item, ...itemmust be a variable or literal
Math Operators
[edit | edit source]+(Add)-(Subtract)*(Multiply)/(Divide)MOD(Modulus)^(Exponent)
Relational Operators
[edit | edit source]>(Greater than)<(Less than)>=(Greater than or equal to)<=(Less than or equal to)==(Equal to)!=(Not equal to)
Logical Operators
[edit | edit source]AND(And)OR(Or)NOT(Not)
Conditional Statements
[edit | edit source]If condition Then
statements
End If
If condition Then
statements
Else
statements
End If
Select expression
Case value:
statements
Case value:
statements
Default:
statements
End Select
Loop Statements
[edit | edit source]While condition
statements
End While
Do
statements
While condition
Do
statements
Until condition
For counter = start To end
statements
End For
For Each variable In array
statements
End For
Subroutines
[edit | edit source]Module ModuleName(DataType ParameterName, ...)
statements
End Module
Function DataType FunctionName(DataType ParameterName, ...)
statements
Return value
End Function
Call ModuleName(parameter, ...) Variable = FunctionName(parameter, ...)
File Processing
[edit | edit source]Declare InputFile VariableName
Declare OutputFile VariableName
Declare OutputFile AppendMode VariableName
Open VariableName FileName
Read VariableName VariableName
Write VariableName item
Close VariableName
Open VariableName FileName
While NOT eof(VariableName)
statements
End While
Close VariableName
Rename FileName, NewName
Delete FileName
Classes
[edit | edit source]Class ClassName
Private DataType FieldName
...
Public Module ModuleName(DataType ParameterName, ...)
statements
End Module
...
Public Function FunctionName(DataType ParameterName, ...)
statements
End Function
....
End Class
Declare ClassName VariableName
Set VariableName = New ClassName()
Bibliography
[edit | edit source]- Gaddis, T. (2016). Starting Out with Programming Logic and Design, 4th Edition. Pearson. ISBN 9780133998160