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, debugging, and maintaining a computer program. Moreover, a good program should have clarity and simplicity of expressions, should make use of the proper name of identifiers, contain comments, and have a proper indentation. Besides, it should be free from all types of errors such as syntax errors, runtime errors, and logical errors.
Programming Process Cycle
The steps of programming are as follows:
Writing
This step involves writing the desired output of the code. besides, drawing a flowchart depicting all the steps from beginning to end. Then the programmer writes the first copy of the code on the programming software.
Testing
This step is about testing the code against the test cases. If the output is according to desired test cases, the code is correct.
Troubleshooting
After testing the program we perform the error correction in this step.
Debugging
It is the process of finding the exact location of the error in the code. Errors can be of different types such as syntax errors, runtime errors, and logical errors.
Running
After all these steps the program is run to get the desired output.
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.
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
- Running and Debugging Programs
- Syntax Errors
- Run-time Errors
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. Thus, we can say that logical error is a type of runtime error.
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.
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 Syntax and Logical Errors
Syntax Error | Logical Error |
|
|
|
|
|
|
|
|
|
|
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. What is a logical error?
A3. We can define a logical error as a bug in the logic or algorithm of a program.
Q4. What is the other name for logical error?
A4. Semantic Error