# Running and Debugging Programs

## 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.

### 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 We find the bugs and errors in this process. In this process, we find the location of the error and rectify the error. Here, we identify the cause of the failure of the program. Here, we rectify the error and remove the cause of failure. It is the process that displays the error. In this process, we deduce the error location. The tester performs the testing. The programmer or developer performs the debugging. We do not require design knowledge to perform it. We require design knowledge to perform it. It can be manual or automated. It is always manual. We perform testing on various levels like unit testing, system testing, integrated testing, etc. This is based on bugs and their types.

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.

Share with friends

## Customize your course in 30 seconds

##### Which class are you in?
5th
6th
7th
8th
9th
10th
11th
12th
Get ready for all-new Live Classes!
Now learn Live with India's best teachers. Join courses with the best schedule and enjoy fun and interactive classes.
Ashhar Firdausi
IIT Roorkee
Biology
Dr. Nazma Shaik
VTU
Chemistry
Gaurav Tiwari
APJAKTU
Physics
Get Started

Subscribe
Notify of