IBComputer ScienceProgrammingHLSL
Programming Debugging Guide
Systematic debugging strategies and common error patterns
ProgrammingDebuggingProblem SolvingErrors
The Prompt
Copy this prompt and paste it into ChatGPT to get started
Act as an IB Computer Science tutor. Help me debug this code systematically:
**Types of errors:**
1. **Syntax errors**: Code violates language rules (won't compile/run)
2. **Runtime errors**: Errors during execution (e.g., division by zero)
3. **Logic errors**: Code runs but produces wrong results
**Debugging strategies:**
**1. Read error messages carefully**
- Identify error type and line number
- Understand what error means
- Look at code around indicated line
**2. Use print statements / logging**
- Print variable values at key points
- Track program flow through branches
- Verify assumptions about data
**3. Rubber duck debugging**
- Explain code line-by-line to someone (or rubber duck!)
- Often reveals logic errors
**4. Binary search debugging**
- Comment out half the code
- Narrow down where error occurs
- Isolate problematic section
**5. Check common issues:**
- **Off-by-one errors**: Array indices, loop bounds
- **Uninitialized variables**: Variables used before assignment
- **Type mismatches**: String vs integer operations
- **Scope issues**: Variable not accessible where used
- **Infinite loops**: Loop condition never becomes false
**6. Test with simple inputs**
- Use minimal test case
- Verify expected vs actual output
- Build up to complex inputs
**7. Use debugger tools**
- Set breakpoints
- Step through code line-by-line
- Inspect variable values at each step
**IB Exam Tip:** For pseudocode questions, trace with small inputs
**My code/problem:** [PASTE CODE OR DESCRIBE ERROR]
How to Use This Prompt
1
Click "Use in ChatGPT"
The prompt will be automatically copied to your clipboard and ChatGPT will open in a new tab
2
Paste the prompt (Ctrl+V)
In ChatGPT, paste the prompt and replace the placeholder with your specific question or problem
3
Get detailed help
ChatGPT will provide step-by-step guidance following the prompt's structure and IB standards
Related Prompts
Other prompts that might help with your studies
Need More Help?
Try our free AI chatbot for instant IB help across all subjects, or work with an expert human tutor for personalized support.