Skip to content

3 min read

Debugging and Bugs

A bug is a mistake in a program that causes wrong or unexpected behavior, and debugging is the process of finding its cause and fixing it safely.

Create an account to save your progressFree panel

At a glance

What it is

A bug is an error in a program that makes it behave differently from what it should. Some bugs stop a program from starting, some make it crash while it runs, and some let it run but give wrong results without any warning.

Three common types are syntax errors, runtime errors and logic errors. A syntax error breaks the grammar of the language, so the program cannot be built or started. A runtime error happens while the program runs, such as dividing by zero. A logic error runs without crashing but produces wrong results.

Debugging is a systematic search. A good debugger reproduces the problem, reads the error message, narrows down where the fault is, forms a hypothesis about the cause, tests a fix, and checks related cases.

Inside your account

What an account adds to the pages you are reading.

Practice questions

Multiple-choice questions with answers you can check.

Games

4 short practice games in maths and science.

Glossary and simulators

424 glossary terms in plain English, and browser simulators.

Key ideas

Example

Question: a program computes an average as total divided by count, using whole numbers. For a total of 7 and a count of 2, what appears in languages such as C# or Java? Whole-number division gives 3, not 3.5. The fix is to use a decimal type or convert one of the values first.

Question: the same program crashes when the count is 0. Why? Dividing by zero has no defined result, so the program should check the count before dividing, and stop with a clear message if it is 0.

Common mistakes

Summary

Bugs are program errors that cause wrong or unexpected behavior. Debugging means reproducing the problem, reading the messages, isolating the cause, testing a fix and checking related cases. A patient, step-by-step method works better than guessing.

Frequently asked questions

What is the difference between a syntax error and a logic error?

A syntax error breaks the language rules, so the program will not run until it is fixed. A logic error follows the rules and runs, but the program does not do what it was meant to do.

Is a bug always caused by the code I just wrote?

Not always. Bugs can come from unusual input, from data, from another part of the program, or from the environment. Check recent changes first, but test your assumptions too.

What is a breakpoint?

A breakpoint is a marked line where a debugger pauses the program, so you can inspect variable values before the next line runs.

Related pages

DersTeders AI

A study companion beside your lesson

Ask about the part you are stuck on, follow a solution step by step, and revisit the same topic with fresh examples.

Available from your panel. Sign in to open the AI section there.

The library behind these pages holds 5,082 topics and 201,970 practice questions.

Create your account

Keep your progress in one place

  • Pick up every lesson where you stopped
  • Answer practice questions and see your results
  • Use the simulators and games with one account

Test yourself

5 questions · answers appear as you go

0 / 5
According to the third paragraph, deep earthquakes are useful to geologists mainly because they ______.

Answer: trace the paths of slabs that have entered the mantle. The passage states that the deepest earthquakes cluster along thin, sheet-like structures that read as ancient ocean crust, so the correct completion is that they trace slab paths. The other options fail because the text says nothing about predicting earthquakes or measuring the core.

According to the fourth paragraph, a cold slab should ______ because it is chemically different from the hot mantle around it.

Answer: give up its distinct composition slowly as it sinks. The blank stands where the passage explains what follows from a chemical difference, and the sentence after it says that chemical signals reveal how far a slab travels. Therefore the correct completion is that it gives up its composition slowly, since the passage insists the change is gradual rather than sudden.

Which of the following best expresses the essential information in the passage?

Answer: Deep earthquakes map the paths of cold slabs, which changed how geologists read the mantle.. The passage moves from subduction, to the old disagreement, to seismic evidence, and finally to the use of deep quakes as a record of swallowed slabs. Because the last paragraph draws a practical conclusion from that evidence, the essential information is that deep earthquakes map the paths of slabs.

What did researchers report in the early 1990s that helped settle the argument about slabs?

Answer: That strong, continuous layers existed deep inside the mantle.. Paragraph three says that in the early 1990s researchers reported strong, continuous layers deep inside the mantle and read them as ancient ocean crust. Because those layers were taken as subducted material, they settled the dispute between the fragmentation model and the intact-slab model.

The word swallowed in the fourth paragraph is closest in meaning to ______.

Answer: taken in. In that phrase a cluster of deep quakes may mark material swallowed long ago, which means rock carried down and taken in by the mantle. Because the passage uses the word for rock drawn beneath the surface, taken in is correct, and not set free or spat out.

Türkçe kaynak: Hata Ayıklama ve Profil Analizi