Skip to Content
Logic Errors

Once we have removed the syntax errors and run-time errors, the program runs successfully. But sometimes, the program still doesn’t do what we want it to do or no output is produced. Hmmm…

These types of errors which provide incorrect output, but appears to be error-free, are called logic errors. Logic errors occur when there is a design flaw in your program. These are some of the most common errors that happen to beginners and also usually the most difficult to find and eliminate.

Because logical errors solely depend on the logical thinking of the programmer, your job now is to figure out why the program didn’t do what you wanted it to do.

Some common logic errors:

  • Program logic is flawed
  • Some “silly” mistake in an if statement or a for/while loop

Note: Logic errors don’t have error messages. Sometimes, programmers use a process called test-driven development (TDD), a way to give logic errors error messages and save yourself a lot of headaches!



Run There should be no error messages.

But the program is supposed to output steps from #1 - #10. The program is somehow starting from 0…

Find the logic error.

Folder Icon

Take this course for free

Already have an account?