Pseudocode - Research Article from World of Computer Science

This encyclopedia article consists of approximately 2 pages of information about Pseudocode.
Encyclopedia Article

Pseudocode - Research Article from World of Computer Science

This encyclopedia article consists of approximately 2 pages of information about Pseudocode.
This section contains 318 words
(approx. 2 pages at 300 words per page)

In the specification of algorithms, as well as in consideration of the design and verification of completed programs, it is common practice to use a notational technique called pseudocode. Pseudocode is simply a convention for specifying a procedure or algorithm fragment in a semi-rigorous way that can be followed by programmers. Well-written pseudocode can often be translated line-by-line into program code.

As with program code itself, pseudocode should be well commented so that it can be easily understood. If the pseudocode conventions (the notation used, which is not rigorous and can vary by author's choice and application domain) are somewhat relaxed, then additional comments may not have to be extensive since a fair amount of English-like comments and phrases can be built into the pseudocode fragment itself.

As an example of a pseudocode specification, consider the following. A person is entitled to vote if she is 18 years of age or older, if she is registered to vote in the relevant jurisdiction, and if she has not lost her right to vote on account of a felony conviction. This voter-validation protocol may be specified in the following format, which could be easily converted to a program for asking questions of a prospective voter to determine eligibility. Comments are included after the double slash marks (//).

  • // Variable declaration --
  • LEGAL is 18 // Global variable for age restriction
  • // Query for age, felony convictions, registration
  • input (age) // Query the person's age
  • input (conviction) // Boolean for felony conviction; 0 means not, 1 means yes.
  • input (is_registered) // Boolean for voter registration; 1 means registered, 0 means not.
  • if (age LEGAL) then // If it is true that the person is of legal age
  • if (is_registered) then // If she is registered
  • if (!conviction) then // If it is not true that she has been convicted
  • else
  • print ("Sorry, felons are not allowed to vote")
  • endif
  • print("You can vote")
  • else
  • print ("Sorry, you aren't registered to vote")
  • endif
  • else
  • print ("Sorry, you must wait a little longer to vote")
  • endif
This section contains 318 words
(approx. 2 pages at 300 words per page)
Copyrights
Gale
Pseudocode from Gale. ©2005-2006 Thomson Gale, a part of the Thomson Corporation. All rights reserved.