Pseudocode is an outline of steps that is laid out BEFORE a programmer starts writing code, regardless of programming language. Pseudocode is later used to write the actual programming statements. It expresses the process that the program will run, and contains details of the algorithms used for solutions. For example, a simple pseudocode for finding the average of a list of numbers might be:
1. Get each of the numbers in a list
2. Calculate the sum of the numbers
3. Determine the quantity of numbers added
4. Divide the sum by the quantity
5. Report the results
Note that this routine can be coded in any programming language, so it is NOT language-specific. Pseudocode cannot be compiled nor executed, and there are no real formatting or syntax rules, yet it is a very important step in producing the programming code. It is critical because it enables a programmer to concentrate on the algorithms without worrying about all the syntactic details of a particular programming language. Many programmers write their pseudocode before even deciding which programming language will be used for the actual program.
For our class, please use the following pseudocode guidelines:
- Program must be written from the pseudocode submitted - not as an afterthought.
- The pseudocode MUST be shown in comment statements at the beginning of the source code, therefore you must type it out, regardless of whether you hand-wrote previous versions of it during its development. This is OK – professional programmers often start with informal pseudocode written on napkins or scrap paper, but formalize it as it matures, then finally document it in text.
- The more detail on what your program is doing, the better. When describing your problem solution algorithm (step 1, step 2, …step n), follow this rule: when in doubt, include it in the pseudocode.
- Standard C++ items such as preprocessor directives and variable declarations should NOT appear in our class problem’s pseudocode – remember pseudocode is just a series of problem solution steps and is NOT written in programming code.