Wednesday, 9 June 2021

CLASS 11 CS CHAPTER 6

 

CLASS -11  COMPUTER  SCIENCE

                 CHAPTER- 6  DEBUGGING PROGRAMS 


🔔To download textbook pdf click on the ''DOWNLOAD'' button below -

DOWNLOAD TEXTBOOK



NOTES FOR COMPLETE UNDERSTANDING -

  • Always whenever we create a program there might be some errors in it.

  • And a programmer needs to find these errors and should fix them to make the  program error free. This  is referred as debugging.

  • What is Debugging?
  • It is the procedure of searching errors, their reasons of occurrence and scientific procedure of their fixation. 

  • ERRORS and EXCEPTION :
  • Errors and Exception, both disturbs the Execution of Program .
  • Errors, usually pop out at the time of translation. 
  • While, Exception gets generated during program running , due to an input.
  • An error is often referred as a bug .
  • It is a code that prevents a program from running successfully and correctly .
  • Some errors are less dangerous in nature whereas some are very trachareous. Some errors are very burdensome to find. 

  • Errors are of 3 types namely –                                                                                              • Compile Time Error             • Run Time Error             • Logical Error

  • Compile Time Error :
  • Errors are  of basically 2 types –                                                                                   • Syntax Error : Violation of formal protocols of a programming language results in syntax error. For eg. x=(x*y)                                                                                      • Semantics Error: keyword Semantics refers to the set of protocols which sets the  meaning  of  statements. A senseless statement results in semantics error. For eg. x * y = z

  • Logical Error :
  • If a program is not giving expected output and also not showing any other error it may be possible that program is having a logical error.                                        This error generates due to wrong implication thought by programmer.                                    For eg-  • To use a variable without initialising value.                                                               • To provide wrong parameters to any function.                                              

  • Run Time Error :
  • These errors generates during a program execution .
  • These errors are hard to find out.
  • Some run time errors obstructs a program from execution which is known as program crash or abnormal termination of program.
  • Many run time errors like infinite loop or wrong value are easier to detect.
  • It is important to safeguard a program from getting crashed in case of run time error.   A program should be robust.

  • Exception:
  • Exception is a stage when a program ends abnormally and it cannot be controlled. For eg. - • a=10                                                                                                                                • b=0                                                                                                                                  • c=a/b -----> (Mathematical Exception)                                                                      – Inputting wrong account number in an ATM is an error.                                        – But receiving less/more amount than expected is an Exception . An exception cause unexpected ending of a program.

  • Exception Handling in Python :
  • try and except clauses are good tools to handle an exception. Any block which has the probability of occurring an exception, that block is to be written under try clause and the code to handle the exception is to be written under except clause. Syntax is as under :                                                                                                                                                try:                                                                                                                                             # code with max possibility of exception will be written here.                            except:                                                                                                                                          #code to handle above exception will be written here.

  • Some Built-in exceptions:



  • How to debug a program? 
  • Compile time error is debugged before program run.
  • Logical error is  solved by Testing.
  • Testing is used with some sample values to check the correct execution of the program.
  • Below are some techniques of debugging-                                                                                  – To identify the place of Error generation.                                                                  – By printing step wise value of Variable.                                                                      – By tracing the Program Code.



             🔔MORE MATERIALS TO BE UPLOADED STAY TUNED🔔




WHY Software Developer ?