You are on page 1of 2

Pseudocode Help

Pseudocode for your programs require the following elements:

1.) A Module main() to start the program


2.) Declaration of variables at the beginning of the program
3.) Steps that you want to accomplish in the program
4.) An end to the program

Module main()
This is required for all programs. It represents the start of the program. The first line in your
Pseudocode must be Module main( ) followed by the remaining steps for the program.

Declaration of variables
Variables have to be declared in your program in order for you to use them. Variables require
three items when declaring them: The Declare keyword, followed by the data type for the
variable (Integer, Real, or String), and finally the name of the variable. Variables should be one
word or two words joined with an underscore. For example, Declare Integer age or Declare Real
user_weight

Steps you want to accomplish


The steps can vary depending on what you want the program to do. You can display data to the
user, get information from the user, call modules/functions in the program, etc.
Note: If you call a module or function in a program, you will have to explain what it does after
you close out the Module main().

End to the program


When you are finished with the program, a module, or function, you have to close it. To close
out the program use the End keyword. For example, End Module or End Function

Let us take a look at two example programs from beginning to end using the steps listed above.

Example One - This program will ask the user to enter in their name and display a thank
you message
//Start the program
Module main()
//Declare variables
Declare String name

//Steps you want to accomplish in the program


Display “Please enter your name: “
Input name
Display “Thank you for running the program “, name

//End the program


End Module

Example Two – This is a modular program that will ask the user for two numbers, will add
the results, and display the results back to the user. Two additional modules will be used
addNumber() and displaySum()

//Start the program


Module main()
//Declare variables
Declare Integer number_one
Declare Integer number_two
Declare Integer summation

//Steps you want to accomplish in the program


Display “Please enter the first number in the calculation: “
Input number_one
Display “Please enter the second number in the calculation: “
Input number_two

Call addNumber(number_one, number_two, summation)

Call displaySum(summation)

//End the program


End Module

//This module takes the two numbers entered by the user, adds them together, stores
the value in the variable sum, and sends that information back to the Module main()
Module addNumber(Integer num1, Integer num2, Integer Ref sum)
Set sum = num1 + num2
End Module

//This module will display the sum to the user


Module displaySum(Integer sum)
Display “The sum of the two numbers that you entered was: “, sum
End Module

You might also like