3 Common Programming Errors
When you starting to learn making program, you will realize that a program rarely runs correctly the first time it compiled. Murphy’s Law, “Anything that can go wrong — will go wrong.” seems right in this case. In fact, errors are so common in programming world that they have their own name “bugs” and the process to fix them is debugging a program. I will show you 3 Common Programming Errors in this article.
Compile-Program-meme 3 Common Programming Errors
When a compiler detects an error, it will displays an error messages. Which indicates that your program is gone wrong. Unfortunately, Most beginner programmer having trouble to interpret it and sometimes misleading. As you gain experience, you will become more proficient at identifying and correcting program errors.
There are 3 kinds of common errors in Programming, they are
- Syntax Errors
- Run-Time Errors
- Logic Errors
Syntax Errors, The Most Common Programming Errors
Syntax error are most common error among beginners. This kind of error occurs when your code violates one or more grammar rules of programming language and the compiler failed to translate your program. If a statement has a syntax error, it cannot be translated and it will not be executed. Let’s take a look at C Language Program example below.
123456789101112#include <stdio.h>#define Meters_Per_KM 1000int main (void){<span style="color: #ff0000;">double meters</span>printf("Enter the distance in KiloMeters :");<span style="color: #0000ff;">scanf("%lf, &kilometers);</span><span style="color: #0000ff;">meters = Meters_Per_KM * kilometers;</span><span style="color: #ff6600;">prinf("That equals %f meters.\n", meters);</span>return(0);}
That example shows a listing of a Kilometers to Meters program. The program contains the following syntax errors:
- Missing semicolon at the end of variable declaration (Red line)
- Using an undeclared variable kilometers (Blue Lines)
- Mistyped function printf (Orange Line)
Run-Time Errors
Unlike Syntax Errors, Run-Time Errors is detected after or during the execution of a program. A run-time error occurs when the program performing an illegal operation (Such as dividing a number by zero, and etc). When a run-time error occurs, the computer will display a diagnostic message that indicates the line where the error was detected.
Many execution errors may not detected (displaying a diagnostic message), but they may simply lead you to incorrect output result. In order to identifying it, it’s essential that you testing it by predict the result of your program should produce and verify that the actual output is correct.
Logic Errors
Compile-meme-286x300 3 Common Programming ErrorsLogic Errors, another common programming errors, happen when program executing a faulty algorithm. Because this error usually do not display an error messages and do not cause run-time errors. They are very difficult to detect. So it’s very important to prevent logic errors by carefully manual checking the algorithm and the entire program before you type it in. Because debugging/fixing this kind of error can be time-consuming. Plan your program’s source code carefully and manually check them to eliminate the bugs early. By preventing Logic Errors, it will save time and avoid trouble.
You May Want to See :
- R vs Python, Which one is better R vs Python, Which one is better
- Learn Android Programming From Scratch Learn Android Programming From Scratch
- Basic Guide of Interprocess Communication and Pipes Basic Guide of Interprocess Communication and Pipes
- String Functions PHP String Functions PHP
- Understanding the basics of HTML Understanding the basics of HTML
- Parallel Programming with Multiprocess and Threads Parallel Programming with Multiprocess and Threads
- Connecting Ruby to Java Programming Connecting Ruby to Java Programming
- How Botnets Infiltrate & Exploit Computer Systems How Botnets Infiltrate & Exploit Computer Systems
- Basic Operators in Python Programming Basic Operators in Python Programming
- Reading Files Without Filehandle PHP Reading Files Without Filehandle PHP
- How to Create iOS Swift “Hello World” Program How to Create iOS Swift “Hello World” Program
- What is CSS and What CSS can do ? What is CSS and What CSS can do ?
- Enumerations in Swift Programming Enumerations in Swift Programming
- How to Test and Debug A Program How to Test and Debug A Program
- User Defined Functions in MySQL User Defined Functions in MySQL
- Recursive Function in Program
- Handling with Objects and Classes in PHP Handling with Objects and Classes in PHP
- Prevent Internet Explorer Crashing and Make It Faster Prevent Internet Explorer Crashing and Make It Faster
- How To Create a Web Crawler and Data Miner How To Create a Web Crawler and Data Miner
- How To Create a Simple Search Engine How To Create a Simple Search Engine
- How to program ghost notes for your MIDI drum tracks How to program ghost notes for your MIDI drum tracks
This site uses Akismet to reduce spam. Learn how your comment data is processed.