Concepts of Programming Methodology
Programming is basically solving a particular problem by giving coded instructions to the computer. Furthermore, the whole scenario of the programming cycle involves writing, testing, troubleshooting, running and debugging programs, and program maintenance. Moreover, a good program should have clarity and simplicity of expressions, should make use of proper names for identifiers, contain comments, and have a proper indentation and documentation.
Running and Debugging Programs
After writing a program, we need to run and test the program. Testing means running each instruction and checking the validity of output. Furthermore, after testing we can know about the errors in the program. Besides, then we can solve and correct these errors and make the program error-free. We can do this by debugging the program. This means finding the location of the error and then resolving it by making necessary changes. There can be several types of errors therefore, running and debugging programs are necessary. Let us learn about several types of errors.
Types of Errors while Running and Debugging Programs
There are several errors which we can face while running and debugging programs. These are as follows:
Syntax Error
We can define these types of errors basically as grammatical errors. Like in any other language, each programming language has its own set of rules and way of writing the program. Moreover, these rules are per the grammar of each programming language. Furthermore, if the programmer violates any of these rules this is the syntax error.
Besides, most of the IDEs (Integrated Development Environments) identifies such errors while you are writing the program. Therefore, you can correct them at the spot only else, the compiler detects the error and notifies during compilation.
For example,
int a;
print(“value of variable a is”,a)
Here, ‘;’ is missing from the print statement. Hence, the compiler gives the error and doesn’t show the output until we rectify it.
Logical/Semantic Error
If your program is syntax free it will compile successfully. But, if the logic is incorrect it is not necessary that you get the desired output. Therefore, such errors are logical or semantic errors. Usually, such errors are indicated during run time. Since the program has no syntax errors, therefore, it runs successfully. But, it is not necessary that you get the expected output. Hence, in such cases, we have to check the program for logical errors.
For example,
int a=10;
if (a%10=0)
{
printf("divisible by 10");
}
In this program logic, the user needs to check divisibility by 10. But, in the ‘if’ condition instead of using ‘==’ it is ‘=’ which is the assignment operator. Therefore, we need the ‘==’ operator to check if the remainder is equal to 0 or not.
Browse more Topics Under General Concepts of Programming Methodology
- Clarity and Simplicity of Expressions
- Use of Proper Names for Identifiers
- Comments
- Indentation
- Documentation
- Program Maintenance
- Syntax Errors
- Run-time Errors
- Logical Errors
Runtime Error
These types of errors are detected during the runtime. Moreover, such errors cause unusual termination of the program. Some examples of such errors are as follows:
- dividing a number by 0
- infinite loop
- wrong input by the user
Difference Between Testing and Debugging
Differences between testing and debugging are as follows:
Testing | Debugging |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Frequently Asked Questions (FAQs)
Q1. What is the running and debugging of programs?
A1. Running is to run the program to get the output. While debugging is finding the location of an error.
Q2. Name the types of errors.
A2. Types of errors are as follows:
- Syntax error
- Logical/Semantic error
- Runtime error
Q3. State true or false:
A semantic error is the violation of syntax rules of a programming language.
A3. False, this type of error is the syntax error, not the semantic error.
Leave a Reply