Pseudocode is a fictitious representation of a typical computer programming language. Statements are entered using English words. The desired operations are represented in the pseudocode. Depending on the developer, the results may be relatively similar to an established language, but they don't have to be. The purpose is to declare program steps in a method which primarily conveys the ultimate purpose. Given the results, a programmer familiar with a programming language should be able to perform a direct translation from the pseudocode to a working computer program.
An algorithm is a set of steps that are followed to build an end product. A recipe is a good real life example. To bake a cake, follow the recipe algorithm. The steps of the process are outlined in sufficient detail to make a cake. Note that the recipe doesn't specify everything in the finest detail. For example, when two cups of flour are called for, the recipe does not require that a particular type of measuring cup be used. Instead, it is important to accomplish the step. The actual measuring cup is the choice of the baker. A computer algorithm is similar. Consider the following step:
"Display the date"
This tells the programmer to make a program perform the operation. Depending on the needs of the program, this might be all that is required. The programmer would perform the step and meet the requirement of the algorithm. Using pseudocode, the programmer might take the algorithm step and establish a series of component steps. Here is an example:
"Determine the current date"
"Set up a display field"
"Load the display field with the current date"
"Write the display field to the computer screen"
These progressive enhancements have conveyed more process information than the earlier algorithm step. None are actually usable by a computer, though. Each needs to be converted to even more detailed steps before they can be executed by a computer. The process is very helpful, however. Here is a famous programming algorithm that has long been used as an exercise for beginner computer programmers:
"Write the words "Hello world" on the computer screen"
This is a very concept, one that every programming language, (and programmer), should be able to do. The concept is very elementary but the implementation is vastly different depending on the operating environment. The best selling book "The C Programming Language", described the process on the UNIX system. The actual code to perform "Hello world" in the book was simple in "C". In that language, the "printf" statement is used to display text on a computer screen. The actual display is written as follows in that language:
printf("Hello world ");
This is an example of an actual statement that can be understood by a computer programming language. Consider the following:
Algorithm: Display a hello world message
Pseudocode: print("hello world")
C Language: printf("Hello world ");
BASIC Language: print "Hello world"
PHP Language: echo "Hello world"
The point is that the final result should work in a real programming language. The early steps of determining program requirements can use an algorithmic approach, pseudocode development or a combination of the two. The end result should be the same. Given the same algorithm, (or pseudocode), a C programmer and a BASIC programmer should finish with working programs to accomplish the task. Because the languages are different, the results will be different. Surprisingly, two C programmers given the same algorithm may write different programs as well. That is because there are various options available in the programming language. While the "printf" statement displays output on a computer screen, there are other statements available to do the same thing. Some may be easier, some harder than "printf", but they all result in the same text display. This is similar to the recipe example. Whether a plastic or glass measuring cup is used for flour, the cake should turn out the same.
Beginners should try to develop simple programs using algorithms and pseudocode, paying attention to the computer fundamentals of input, processing and output. Here is a valid example:
Get the order details
Calculate the cost of the order
Print a recipt
A computer can easily perform these steps. There are millions of computer applications that accept order details, calculate totals and print receipts. There is no computer that can perform these steps directly, though. The steps are too vague. Here is a progression of the steps into a more detailed algorithm:
Get the item number
Get the quantity
Calculate the order cost, quantity times unit price
Add sales tax
Compute final total
Print a receipt showing item number, description, quantity, unit cost, total cost and tax due
It is obvious that this algorithm is better than the earlier example, but it is still not an actual program. A programmer, however, might be able to take this and develop a working program. Since the algorithm is still vague, the programmer is likely to come up with a solution that is different that what the designer envisioned. Further elaboration may both improve the accuracy of the resultant program and speed up the development process.
As a computer programming beginner, you can concentrate on specifying what to do, not how to do it. Using algorithms and pseudocode, requirements can be developed that can be easily translated into actual computer code. This is true regardless of the target computer language. Most programming languages are based on English so develop your algorithms in that language.