Pseudocode is part English, part program logic, its purpose is a describe, in precise algorithmic detail, what the program being designed is to do. This requires defining the steps to accomplish the task in sufficient detail so that they can be converted into a computer program. It was made up of 2 Words : Pseudo and code.
Pseudo means imitation and code refers to instructions, written in a programming language.
It does not obey the syntax rules of any particular language.
It is not real programming code.
Keywords for writing Pseudocode.
Input : READ, OBTAIN, GET Output : PRINT, DISPLAY, SHOW Compute : COMPUTE, CALCULATE, DETERMINE Initialize : SET, INIT Add one : INCREMENT, BOMP.
List the Guidelines for Writing Pseudocode :
Any language should be used for writing statements. Statements should be long independent.
- It must produce solution.
- Logic must be decomposed to a level of single loop or decision.
Example : Not like search the list and find the customer with highest balance.
- Write each instruction in separate line.
- Should be concise : Ignore unnecessary details.
- Use programming shorthands - if-then-else etc. without writing equivalent english.
- If it can not be translated to working code means something is wrong.
- Keywords should be highlighted by capitalizing them.
- Type of variable used is clear from context.
Benefits of Pseudocode :
- Allow designer to focus on logic of algorithm, not on details of long syntax.
- It is long independent.
- It can be translated to any computer language code.
- Unlike flowcharts, pseudo codes are concise, more readable and easier to modify.
- It allows designer to express the design in plain natural languages.
Guidences for Pseudocode & Algorithm :
In text and lecture, algorithm are often expressed in pseudocode. Both are almost same.
Guidenlines for algorithm and pseudocode are.
- Each Algorithm will be logically enclosed by 2 statements START, STOP
- To accept data from user, INPUT or READ statement is to be used.
- To display any used message or content of variable, PRINT statement is used. Message should be enclosed within quotes.
- Assignment : =
- Arithmetic Operator : +(Add), -(Sub), *(Mul), /(Div)
- Relational : >, >=, <, <=, ==, !=
- Logical : AND - ( && ), OR - ( || ), NOt - ( ! )