< Pseudocode

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

Data Types:

  • Integer
  • Real
  • String
  • Character

Syntax:

  • Declare DataType VariableName
  • Declare DataType ArrayName[Size]

Constants

Syntax:

  • Constant DataType Name = Value

Comments

Syntax:

  • // Comment

Input / Output

Syntax:

  • Input VariableName
  • Display item, ...
    • item must be a variable or literal

Math Operators

  • + (Add)
  • - (Subtract)
  • * (Multiply)
  • / (Divide)
  • MOD (Modulus)
  • ^ (Exponent)

Relational Operators

  • > (Greater than)
  • < (Less than)
  • >= (Greater than or equal to)
  • <= (Less than or equal to)
  • == (Equal to)
  • != (Not equal to)

Logical Operators

  • AND (And)
  • OR (Or)
  • NOT (Not)

Conditional Statements

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

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

Module ModuleName(DataType ParameterName, ...)
    statements
End Module
Function FunctionName(DataType ParameterName, ...)
    statements
    Return value
End Function
Call ModuleName(parameter, ...)
Variable = FunctionName(parameter, ...)

File Processing

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

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

  • Gaddis, T. (2016). Starting Out with Programming Logic and Design, 4th Edition. Pearson. ISBN 9780133998160
This article is issued from Wikiversity. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.