< Previous | Contents | Next >

Using Pseudocode

Many programmers sketch out their programs using pseudocodea language that falls somewhere between English and a formal programming language. Anyone who understands English should be able to follow pseudocode. Heres

140 Chapter 4 n The Standard Template Library: Hangman


an example: Suppose I want to make a million dollars. A worthy goal, but what do I do to achieve it? I need a plan. So I come up with one and put it in pseudocode.

If you can think of a new and useful product Then that’s your product

Otherwise

Repackage an existing product as your product Make an infomercial about your product

Show the infomercial on TV

Charge $100 per unit of your product Sell 10,000 units of your product

Even though anyone, even a non-programmer, can understand my plan, my pseudocode feels vaguely like a program. The first four lines resemble an if statement with an else clause, and thats intentional. When you write your plan, you should try to incorporate the feel of the code that youre representing with pseudocode.