How to write Pseudocode?
Before writing the pseudocode of any algorithm the following points must be kept in mind.
- Organize the sequence of tasks and write the pseudocode accordingly.
- At first, establishes the main goal or the aim.
Example:
This program will print first N numbers of Fibonacci series.
- Use standard programming structures such as if-else, for, while, and cases the way we use them in programming. Indent the statements if-else, for, while loops as they are indented in a program, it helps to comprehend the decision control and execution mechanism. It also improves readability to a great extent.
Example:
IF “1”
print response
“I AM CASE 1”IF “2”
print response
“I AM CASE 2” - Use appropriate naming conventions. The human tendency follows the approach of following what we see. If a programmer goes through a pseudo code, his approach will be the same as per that, so the naming must be simple and distinct.
- Reserved commands or keywords must be represented in capital letters.
Example: if you are writing IF…ELSE statements then make sure IF and ELSE be in capital letters.
- Check whether all the sections of a pseudo code are complete, finite, and clear to understand and comprehend. Also, explain everything that is going to happen in the actual code.
- Don’t write the pseudocode in a programming language. It is necessary that the pseudocode is simple and easy to understand even for a layman or client, minimizing the use of technical terms.
Good vs Bad ways of writing Pseudocode:
What is PseudoCode: A Complete Tutorial
A Pseudocode is defined as a step-by-step description of an algorithm. Pseudocode does not use any programming language in its representation instead it uses the simple English language text as it is intended for human understanding rather than machine reading.
Pseudocode is the intermediate state between an idea and its implementation(code) in a high-level language.