0% found this document useful (0 votes)
15 views11 pages

Data Handling Part 6 Ip New

The document explains debugging, which is the process of identifying and fixing errors in a program. It categorizes errors into compile time errors (syntax and semantics), run-time errors, and logical errors, detailing their characteristics and examples. Additionally, it discusses exceptions and introduces code tracing as a technique for debugging by monitoring variable changes during execution.

Uploaded by

ashugamerz1988
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views11 pages

Data Handling Part 6 Ip New

The document explains debugging, which is the process of identifying and fixing errors in a program. It categorizes errors into compile time errors (syntax and semantics), run-time errors, and logical errors, detailing their characteristics and examples. Additionally, it discusses exceptions and introduces code tracing as a technique for debugging by monitoring variable changes during execution.

Uploaded by

ashugamerz1988
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Data Handling

Std XI – Computer Science / Informatics


Practices
Part 6
Debugging
Debugging means to remove bugs from the program.
Program bug – An error causing disruption in program’s
running or in producing right output.
Debugging involves rectifying the code so that the reason
behind the bug gets resolved and thus the bug is also
removed.
Debugging refers to the process of locating the place of
error , cause of error, and correcting the code accordingly.
Errors in a program
An error or bug is anything in the code that prevents a
program from compiling and running correctly.
They are of three types:
1. Compile time errors
A. Syntax error
B. Semantics error

2. Run time errors


3. Logical errors
Compile time Errors
Errors that occur during compile time are known as compile time errors.
When we compile a program the source code is checked for whether it
follows the programming languages rules or not.
1. Syntax errors : This error occurs when rules of programming
language are misused. ie when a grammatical rule is violated.
Eg. X<-Y*Z # <- is not an assignment operator.
X=Y*Z is correct
If X=(X*Y) # = cannot be used, if requires colon: If
X==(X*Y) : is correct

Syntax :Syntax refers to formal rules governing the construction of


valid statements in a language.
2. Semantics errors: This error occurs when statements
are not meaningful.
Example  “Sita plays guitar “ is syntactically and
semantically correct.
But “Guitar plays Sita” is syntactically (grammatically)
correct but semantically incorrect.

Example  X*Y = Z #will give error


Semantics refers to the set of rules which give the
meaning of a statement.
Logical errors
Sometimes there is no error during compile time and
runtime but the program does not give desired o/p .This is
due to the wrong logic used by the programmer.
Example  passing wrong arguments, loop not ended, etc.
These errors are hardest to prevent and locate
Run-time error
Errors that occur during the execution of program are run-
time errors.
These are harder to detect errors.
Program may crash or abnormally terminated.
Most run time errors are easy to identify because the
program halts when it encounters them. Eg – infinite loop,
wrong value in input, or different data type
A program that crashes whenever it detects error
condition is not desirable. There a program should be
robust so as to recover and continue following the error.
Exception
Errors and exception are similar but in different terms.
Error represents any bug in a program whereas exception
refers to any irregular situation occurring during execution/
run time , which you have no control on.
Error can be removed by correcting the program, fixing
exception is not simple.
Example 
If you operate an ATM machine then,
1. Entering wrong account number or pin is an error.
2. not enough money in account, ATM machine stuck is an
exception
So, exception occurs during runtime and you do not have
any control on it.
Example  You write a code that opens a data file and
displays it on the screen, this program is syntactically and
logically correct but when you run it , the file that you are
opening does not exist on the disk – this will cause
exception .

Example 
>>> 100/0
ZeroDivisionError
>>>int(‘11ab’)
ValueError
Debugging using code tracing
Most common technique to debug an error is to find the point of
error and origin of error.
This is often done by printing the values of every intermediate
results and of all values.
For this code tracing is one most commonly used technique.
Code tracing means executing code one line at a time and watching
its impact on variables.
One way of code tracing is dry run .(explained in earlier lesson)
Code tracing can also be done by debugging tools or debug
available in software form.

You might also like