Documentation


Table of Contents

Main Method


Data Types


Variables


Named Constants


Arrays


Input and Output


If Statements


Select Case


Loops


Examples




Main Method

Each program must have a main method surrounding it:
Module main()
 statement
 statement
 statement
End Module



Data Types

Integer
Real
String
Character
Boolean


Variables

To declare a variable:
Declare DataType VariableName
To set the value of a variable:
Set variableName = value

Named Constants

To declare a named constant:
Constant DataType Name = Value

Arrays

To declare an array:
Declare DataType ArrayName[Size]
To set an array element:
Set arr[index] = value

Input/Output

To display output:
Display var
Display "This text will be displayed as is"

To read input:
Input variableName

Operators

Arithmetic Operators:
+ , - , * , / , ^ , MOD
Relational Operators:
== , < , > , <= , >=
Logical Operators:
AND, OR, NOT

If Statements

To create an If-Then statement:
If condition Then
 statement
 statement
 etc
End If

To create an If-Then-Else statement:
If condition Then
 statement
 statement
 etc
Else
 statement
 statement
 etc
End If

To create an If-Then-Else-If statement:
If condition Then
 statement
 statement
 etc
Else
 If condition Then
  statement
  statement
  etc
 statement
 etc
 End If
End If


Select Case

To create a select case:
Select testExpression
 Case value_1
  statement
  statement
  etc
 Case value_2
  statement
  statement
  etc
 Default
  statement
  statement
  etc
End Select

Loops

To create a While loop:
While condition
 statement
 statement
 etc
End While

To create a Do-While loop:
Do While condition
 statement
 statement
 etc
End Do While

To create a For loop:
For counterVariable = startingValue To maxValue
 statement
 statement
 etc
End For

To create a For loop with Different Increments:
For counterVariable = startingValue To maxValue Step incrementAmount
 statement
 statement
 etc
End For

Note: Count variables do not get deleted after the for loop completes in our Pseudocode

Examples



Example Program 0-1: Hello World

Display "Hello world"


Example Program 0-2: Pay Calculating

Display "Enter the number of hours the employee worked."

Input hours

Display "Enter the employee's hourly pay rate."

Input payRate

Set grossPay = hours * payRate

Display "The employee's gross pay is $", grossPay


Example Program 2-1: Display

Display "Kate Austen"Display "Kate Austen"

Display "1234 Walnut Street"

Display "Asheville, NC 28899"

Example Program 2-2: Input Age

Display "What is your age?"

Input age

Display "Here is the value that you entered:"

Display age


Example Program 2-4: Self Info

Display "Enter your name."

Input name

Display "Enter your age."

Input age

Display "Hello ", name

Display "You are ", age, " years old."


Example Program 2-6: Set Dollars

Set dollars = 2.75

Display "I have ", dollars, " in my account."

Set dollars = 99.95

Display "But now I have ", dollars, " in my account!"


Example Program 2-7: Set Price

Set price = 100

Set discount = 20

Set sale = price - discount

Display "The total cost is $", sale


Example Program 2-10: Test Score Average

Display "Enter the first test score."

Input test1

Display "Enter the second test score."

Input test2

Display "Enter the third test score."

Input test3

Set average = (test1 + test2 + test3) / 3

Display "The average score is ", average


Example Program 2-12: Declaring Variable Types

Declare Integer age

Display "What is your age?"

Input age

Display "Here is the value that you entered:"

Display age


Example Program 2-14: Documentation

// Declare the variables

Declare Real fiveYears

Declare Real sevenYears

Declare Real tenYears

// Create a constant for the yearly rise

Constant Real YEARLY_RISE = 1.5

// Display the amount of rise in five years

Set fiveYears = YEARLY_RISE * 5

Display "The ocean levels will rise ", fiveYears,

" millimeters in five years."

// Display the amount of rise in seven years

Set sevenYears = YEARLY_RISE * 7

Display "The ocean levels will rise ", sevenYears,

" millimeters in seven years."

// Display the amount of rise in ten years

Set tenYears = YEARLY_RISE * 10

Display "The ocean levels will rise ", tenYears,

" millimeters in ten years."

Back to Top
Back to Top