Algorithms
An algorithm is a basic idea of a program before any code is actually written. There are a few ways in which this can be done, the two most common are through flowcharts and pseudocode. Once you have been programming for a while, one can usually make a flowchart in their mind without actually writing anything down.
Pseudocode- pseudo meaning fake, code meaning instructions in which the computer understands
When we say pseudocode, what we really mean is a simple outline of your program. Pseudocode is usually written in plain english, with each instruction being written on one line. The program starts at the top of the page, and works its way down, just like any program, with functions being in a seperate from the main page.
…
Pseudo code goes here
…
End Main ProgramFunctions
…
Your Functions would go here
…
End Functions
Flow charts are another way to outline your program. With flow charts the information for the program would be in symbols specifically designed for that statement. Here are a list of symbols:
Terminal Symbol This symbol indicates a beginning or ending point in a flowchart. Every chart should begin and end with this symbol. |
|
Input/Output Symbol This symbol represents input coming in from the keyboard, a file, or elsewhere, or that information is being written to a disk or the screen. |
|
Process Symbol This symbol represents any single process in an algorithm. Processes include Mathematical functions and other things of that nature. |
|
Predefined Process This is a predefined module/function and has its own flowchart. |
|
Decision Symbol The decision symbol is used when a program needs to make a decision. Usually used with if statements, but can be used with other decision making structures. |
|
Flow Lines Flow lines connect the symbols in a flowchart. They contain an arrow head when the flow isn’t from top to bottom or left to right. |
Personally I feel that flowcharts can get confusing and way too complicated, so I like to stick with the pseudo code. It is important to have a good idea of what your program is supposed to do and what it is expected to do. Sitting down and just writing code trying to make it work anyway possible is not a good way to write code, as it can get complicated and turn into speghetti code. Speghetti code is having code that is all over the place when there is a simple solution.
If you are having problems with your programming, then you are probably getting an error. There are two types of errors: syntax and logic. A syntax error will usually be caught by the compiler, or interpreter. This type of error includes forgetting semicolons in some languages or curly braces in others. Logic errors usually come from user error. Like putting a 3 where it is meant to be a 2. The compiler/interpreter usually won’t catch these and is up to you to catch them.