What is pseudocode?

Pseudocode consists of short, English phrases used to explain specific tasks within a program's algorithm. Pseudocode should not include keywords in any specific computer languages. It should be written as a list of consecutive phrases. You should not use flowcharting symbols but you can draw arrows to show looping processes. Indentation can be used to show the logic in pseudocode as well. For example, a first-year, 9th grade Visual Basic programmer should be able to read and understand the pseudocode written by a 12th grade AP Data Structures student. In fact, the VB programmer could take the other student's pseudocode and generate a VB program based on that pseudocode.

Why is pseudocode necessary?

The programming process is a complicated one. You must first understand the program specifications, of course, Then you need to organize your thoughts and create the program. This is a difficult task when the program is not trivial (i.e. easy). You must break the main tasks that must be accomplished into smaller ones in order to be able to eventually write fully developed code. Writing pseudocode WILL save you time later during the construction & testing phase of a program's development.

How do I write pseudocode?

First you may want to make a list of the main tasks that must be accomplished on a piece of scratch paper. Then, focus on each of those tasks. Generally, you should try to break each main task down into very small tasks that can each be explained with a short phrase. There may eventually be a one-to-one correlation between the lines of pseudocode and the lines of the code that you write after you have finished pseudocoding.

It is not necessary in pseudocode to mention the need to declare variables. It is wise however to show the initialization of variables. You can use variable names in pseudocode but it is not necessary to be that specific. The word "Display" is used in some of the examples. This is usually general enough but if the task of printing to a printer, for example, is algorithmically different from printing to the screen, you may make mention of this in the pseudocode. You may show functions and procedures within pseudocode but this is not always necessary either. Overall, remember that the purpose of pseudocode is to help the programmer efficiently write code. Therefore, you must honestly attempt to add enough detail and analysis to the pseudocode. In the professional programming world, workers who write pseudocode are often not the same people that write the actual code for a program. In fact, sometimes the person who writes the pseudocode does not know beforehand what programming language will be used to eventually write the program.


Original Program Specification:   

Write a program that obtains two integer numbers from the user. It will print out the sum of those numbers.


Prompt the user to enter the first integer
Prompt the user to enter a second integer
Compute the sum of the two user inputs
Display an output prompt that explains the answer as the sum
Display the result

Use this template when typing your pseudocode into MS Word:

John Doe
Visual Basic
Period 1
ProjectName Pseudocode

Specs -

Write a program to calculate the cost of buying material for a dress. Use a textbox to allow the user to enter the number of yards of material. Use a single label to display the final cost along with an appropriate output message. Use $8.50 as cost per yard of the material. The final cost is the cost per yard times the number of yards as inputted by the user. You are guaranteed as a precondition that the user will enter a whole number between or including 1 and 100.

Pseudocode -

- prompt the user to input the number of yards of dress material with a prompt message displayed in a label
- the user inputs the number of yards of material into a text box and clicks a button
- store the user's input (# of yards) into an Integer variable
- multiply the number of yards by 8.5 and store that product in a Double variable
- display the final cost in the Text property of a label concatenated with an output prompt message
- allow the user to exit the program by clicking an Exit button at any time

Wyo Coding Standards