How do you debug a program that is not working as expected ?

Can someone tell me how do you debug a program that is not working as expected  i want the exact answer of that if anyone know then please tell me 

1 Answer

Debugging means finding and fixing errors (bugs) in your program, so it works correctly. Here is a step -by -step guide for effective debugging in your program: 1. Please understand the problem clearly

  • Please read the error message (if any).
  • Do you know what the program should do? What do you do?
  • Try to repeat the problem constantly.

2. Check the code on a line to the line

  • Carefully examine the logic.
  • Look for common mistakes like this:
  • Name of incorrect variable
  • The condition of the false loop Without color or bracket
  • An error in the loop
  • Incorrect indentation (especially in Python)

3. Use a printing phrase

  • Add a printing phrase () to check the variable value or see which part of the code is running.
  • This will help you keep track of as everything goes wrong.
 print("x =", x)  # Check value of x
print("Reached here")  # Check if a block of code runs

We use cookies to enhance your experience, to provide social media features and to analyse our traffic. By continuing to browse, you agree to our Privacy Policy.