C Debugging Intermediate
C Debugging Intermediate
Level)
• Understanding and fixing errors in C programs
Types of Errors
• 1. Syntax Errors
• 2. Runtime Errors
• 3. Logical Errors
Syntax Errors
• Missing semicolon, wrong syntax
• Example: printf("Hello")
Runtime Errors
• Occurs during execution
• Example: Division by zero, file not found
Logical Errors
• Program runs but wrong output
• Example: wrong formula or condition
Debugging Techniques
• Use printf()
• Check conditions
• Trace variables step-by-step
Common Mistakes
• Using = instead of ==
• Wrong loop conditions
• Uninitialized variables
File Handling Errors
• Check if file opened
• Use NULL check
• Handle EOF properly
Pointers Debugging
• Check NULL pointers
• Avoid segmentation fault
• Initialize pointers
Tips for Lab Exam
• Write simple code
• Test with sample input
• Check output carefully
Conclusion
• Debugging improves program accuracy and
efficiency