Tuesday, September 7, 2010

Introduction to Pseudocode

First off, what is pseudocode? It is merely a combination of: pseudo (meaning almost, approaching, or trying to be) and code (the language you are writing in; the set of instructions in a program). It is an informal written representation of your program. In pseudocode you don't need to follow syntax requirements, and really as long as it makes sense to you it doesn't matter how you do it. Here are a few guidelines you can follow however to get the most use out of your pseudocode:

  1. Begin and end your code with terminal statements (i.e. begin,end,start,stop).
  2. Don't use terminal statements if you don't like them.
  3. Use indentation freely to increase readability.
  4. Don't overuse indentation.
  5. Make it make sense to you.
Basically it all boils down to, how do you want to do it? As you learn more about if then, while, do while, statements it becomes more clear what to do. Here is a short example using the same program in my Flowchart introduction.

             start
               input phoneNumber
               call phoneNumber
               if phoneAnswered = no
                 call phoneNumber
               else output "Hello"
             end


Does anyone else have some tips or pointers when using pseudocode?

    No comments:

    Post a Comment