What is Programming
Programming is a sequence of instructions that tells a computer to complete a task using code. Different programming languages are used to tell computers to do different things.
Computer Programming Languages
There are many different computer programming languages that are used for many different purposes. As I mentioned in my Robotics page, the different languages can be used for business, mechanical, and educational purposes. For a larger list of the different computer languages and what they do, please visit the robotics page of my blog.
Process of Programming
1. First, you have to know what you want to program, which will influence which programming language you use. You identify what you know (input – given data) and what you want to get out of the program (output – the result).
2. To help with this process, you can construct a flowchart or write pseudocode. A flowchart is a visual representation of the solution to the problem, and consists of boxes and symbols for actions with arrows for directions. The American National Standards Institute has developed a system of symbols to be used in simple flowcharts.
Pseudocode is a language similar to English. It is more complicated than the regular language, but less complicated than a formal programming language. By using pseudocode, you can focus on the logic and accuracy of the program without having to properly use a specific coding language.
3. The next step is to convert that flowchart or pseudocode into an established computer language. To do this, you have to use the exact syntax of the computer language you are using. Otherwise, the computer will not understand what you are trying to program it to do.
4. While some can write a program perfectly the first time, most people need to test the program to make sure that it runs correctly. There are three steps in testing the program.
First is desk-checking, which is a process in which you proofread your program before you actually run it. This can save you lots of time because you could catch errors before you have to run the actual program.
Next, you could use a translator, a program that checks to make sure you used the proper syntax for your program and converts the program to a form that a computer can easily understand. Usually, the translating program is a compiler, which translates each individual step of the program.
Debugging is the last phase of testing the program, and involves finding and fixing bugs/mistakes in your program. For this step, you create a data test that tests each part of the program to make sure that it runs correctly.
5. The last step in making a program is to document it. A documentation of a program is a written description of the program and its components. It usually includes all of the steps throughout the programming process, including the problem, flowchart/pseudocode, data, and test results. This part of the process enables the people that come after you to understand and improve on your program.
Say you create a program that types “Happy Birthday” five times, and you make a program that says that phrase five times in it. However, if you wanted to type “Happy Birthday” a hundred times, you probably won’t want to be typing those words a hundred times in the program. So, you use a loop, which is a code that helps with repeating a function several times. There are two commonly used loops in the C programming language.First is the while loop. The while loop begins with the word “while”, which is then followed by the condition in parenthesis. Whether the condition is true or false will determine if the code repeats or not. A condition is usually relational and is either true or false, with any non-zero values being true and zero being false. A while loop will keep on repeating itself until the condition proves to be true. Then the program will continue to run commands after the loop body.
The second type of loop is the do…while loop. Where the while loop checks the condition before it completes the loop, the do…while loop runs the loop body before it checks the condition.
In loops, there are also break statements, which immediately halts the loop and has the program start again at the next command after the loop.