How to write Pseudocode - Rules for Pseudocode - Pseudocode in C++

 

How to write Pseudocode - Rules for Pseudocode - Pseudocode in C++

Pseudocode:

  • It is a simpler version of a programming code in plain English which uses short phrases to write code for a program before it is implemented in a specific programming language.
  • It is one of the methods which can be used to represent an algorithm for a program.
  • It does not have a specific syntax like any of the programming languages and thus cannot be executed on a computer.
  • There are several formats which are used to write pseudocodes
  • Many time algorithms are presented using pseudocode since they can be read and understood by programmers who are familiar with different programming languages.
  • Pseudocode allows you to include several control structures such asWhile, If-then-else, Repeat-until, for and case, which is present in many high-level languages.
  • Pseudocode is not an actual programming language.

Rules for Pseudocode:

1. Write only one statement per line.

  • Each statement in your pseudocode should express just one action for the computer.
  • If the task list is properly drawn, then in most cases each task will correspond to one line of pseudocode.

2. Capitalized initial keyword

  • In the example above, READ and WRITE are in caps.
  • There are just a few keywords we will use:
  • READ, WRITE, IF, ELSE, ENDIF, WHILE, ENDWHILE, REPEAT, UNTIL

3. Indent to show hierarchy

We will use a particular indentation pattern in each of the design structures:

  • SEQUENCE: keep statements that are “stacked” in sequence all starting in the same column. 
  • SELECTION: indent the statements that fall inside the selection structure, but not the keywords that form the selection
  • LOOPING: indent the statements that fall inside the loop, but not the keywords that form the loop

4. End multi-line structures. 

  •  All the initial keyword must always in line with the last or end of the structure. 

5. Keep statement language independent.

  • In here, we haven’t used any specific programming language but wrote the steps of a linear search in a simpler form which can be further modified into a proper program. 

Post a Comment

0 Comments