Finding bugs using a debugger
A debugger is a tool that can help us see what happens when a program is running. As we have already mentioned, some bugs can be hard to find and understand just by running the program. Often, we will discover a strange behavior in the program, but it might not be obvious what the reason behind this behavior is.
A debugger is an application that is tailored for a particular programming language and can be used to pause the application at a specified code line. At this point, we can inspect what values all the variables have.
We can also resume the execution of the program or execute it one line at a time to see what happens.
Let's try using a debugger. To do this, we first need to pick a language and then write a small program that contains a logical error. We can take one of the errors that we previously looked at:
if age > 12 or age < 20 then … end_if
Remember that in this example, we accidentally used...