CSC 160 - Pseudo-code Quick Reference
A brief definition (clarification) of what pseudo-code is and what it
should look like
What is pseudo-code
On page 19, our text says:
Pseudo-code is a cross between human language and a programming
language.
The goal of pseudo-code is to describe the design of your solution to a programming
problem. This should ease the C++ implementation of the solution, and your C++
coding should flow fairly easily from your pseudo-code
description.
I will also add the following about pseudo-code:
- It should describe how you are going to solve the problem:
your algorithm
- It should indicate the structure of your C++
solution as well: modules, loops switch and if statements, etc
- It should be in English sentence fragments: not prose and not C++
- You don't have to declare variables or follow a strict syntax with
pseudo-code... do your best to communicate your design solution.
The level of detail in your pseudo-code is somewhat subjective. The
goal of the pseudo-code is for you to describe the important design and
structural decisions you are making about your program. You do not
need to describe the obvious. For example, in communicating with the
user, the full text of messages and menus need not be described
in pseudo-code. Your pseudo-code should not be as detailed as
C++.
Dictionary
Here's your pseudo-code vocabulary... try and use these verbs, where
possible, in your pseudo-code:
- Input, query user, or ask user - to get
information from the user
- Read - to get information from a file
- Display, output, or write - to show
information to the user
- Calculate, assign, or = - to set the value of
something
- Compare - compare the value of two or more things
- if, else, end if - if statement constructs
- switch, case, end switch - switch statement
constructs
- while, end while - while loop constructs
- do, while - do-while loop constructs
- for, end for - for loop constructs
- return - exit a function or module
- call - call a function or module
- Module - being the pseudo-code for a function, class or
module
The use of other English verbs is not prohibited. You should,
however, use these verbs to describe these activities when possible.
Examples in the book
You can find pseudo-code examples for each of my programs on the k:
drive.
Also, here's a list of pseudo-code examples in the book with their
highlights (if any):
- Page 19 - display, input
- Page 153 - ask user, calculate, display
- Page 303 - for
- Page 385 - module, call, switch, do-while
- Page 553 - for, compare
- Page 556 - for, compare, if, return
- Page 590 - set, while, return
- Page 592 - if, else, while
- Page 597 - do-while, call, if, else
- Page 598
- Page 605
- Page 609
- Page 613
- Page 615
- Page 616