Debugging Programs Class 11 Notes

Debugging Programs Class 11 Notes

CBSE Notes Class 11

Students should go through the Debugging Programs Classification Class 11 Computer Science notes provided below. These notes have been designed based on the latest NCERT Book for Class 11 Computer Science. These revision notes cover all important topics in your CBSE books. Students should revise all Class 11 Computer Science Notes as they will help the students to understand all topics given in your books. This will help you to get good marks in the Class 11 Computer Science exams.

CBSE Class 11 Computer Science Chapter 11 Debugging Programs Notes

Errors in a program are known as ‘bugs’.
To remove the errors from a program, known as debugging.


Debugging Programs Class 11 Notes

Compile Time Error
a. Syntax Error
b. Semantics Error
2. Run Time Error
3. Logical Error

  1. Compile Time Error: Compile time errors are those errors that occur at the time of compilation of the program. There are two types of compile time errors:
    a. Syntax Error: These errors occur due to violation of grammatical rules of a programming language. for example:

if a>b #Syntax error, : is missing
Print(“a is greater than b”) # Syntax error, P is capital in Print statement

b. Semantics Error: Semantic errors occur when the statements written in the program are not meaningful.
Example: a+b = c # expression cannot come on the left side of the assignment operator.

2. Run Time Error: Errors that occur during the execution or running the program are known as run time errors. When a program “crashed” or “abnormally terminated” during the execution, then this type errors are run time errors.

Example: When a loop executes infinite time.
while a<5: # value of a is always less than 5, infinite loop

3. Logical Error: These types of errors occur due to wrong logic. When a program successfully executes but giving wrong output, then it is known as logical error.
average=a+b+c/3 #wrong logic to find the average print(average)


11.3 Exception handling in python:
The unusual and unexpected condition other than syntax or logical errors, encountered by a program at the time of execution, is called exception.
The purpose of exception handling mechanism is to provide means to detect and report an exceptional circumstance, so that appropriate action can be taken.
Exception handling in python can be done using try and except blocks.
# Code that may generate an exception
except: # Code for handling the exception

Example: num1=int(input(“Enter first number :”)) num2=int(input(“Enter second number: “)) try: r=num1/num2 print(“Result is :”, r) except: print(“Divided by zero”)


Enter first number :
30 Enter second number:
0 Divided by zero

11.4 Steps to debug a program:
a. Carefully follow the syntax of a language
b. Spot the origin of error
c. Read the type of error and understand it well
d. Use intermediate print statements to know the value and type of a variable
e. Trace the code carefully

Debugging Programs Class 11 Notes