Lec24 - Lecture 24 Debugging PIC 10A Todd Wittman Sec 4.15...

Info icon This preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Lecture 24: Debugging PIC 10A Todd Wittman Sec 4.15 Debugging Strategies square6 The first computer bug on record was an actual bug. A moth got caught in the relay switch of Harvard’s Mark III computer. •Modern bugs aren’t so literal and that makes them harder to track down. •Today we’ll discuss different strategies for tracking down and fixing bugs in your program.
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
2 Sec 4.15 : Debugging Strategies square6 Debugging has 3 basic steps: 1. Recognize that you’ve got bugs. 2. Track down where the bug occurs. 3. Eliminate the bug. square6 Some basic debugging approaches: square6 Run the compiler to track down compile errors square6 Test with reasonable and unreasonable inputs square6 Inserting trace messages square6 Assertion statements square6 Divide and conquer square6 Stepping through the debugger List the Prime Numbers #include <iostream> int main ( ) { cout << "Enter the upper limit: "; cin << n; for (int i = 1; i <= n; i ++) { if (isPrime(i)) cout << i << "\n"; } return 0; } bool isPrime (int n) { if (n==2) return true; if (n%2==0) return false; int k; while (k*k < n) { if (n%k==0) return false k = k+2; } return true; } square6 Print all prime numbers <= some upper limit (p.311). square6 First find the compile errors with the compiler (F7).
Image of page 2
3 List the Compile Errors square6 By now, you’ve become very familiar with the compile errors in the Build window. square6 Correct the errors from the top-down, recompiling after each correction.
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern