In this article types of errors in c we give the information about Error is an unusual condition that stops execution of the program whenever it occurs.
Types of Errors in C Programming
Introduction:
An error is an unusual condition or mistake that occurs during program execution or compilation, which prevents the program from running correctly.
Whenever an error occurs, it either stops the execution of the program or produces an incorrect result.
Errors in C are mainly classified into the following types:
- Compile-Time Errors
- Run-Time Errors
- 
Compile-Time Errors:
If an error is detected during compilation, it is known as a compile-time error.
These errors occur when the programmer violates the syntax or grammatical rules of the C programming language.
Such errors must be corrected before the program can be successfully compiled and executed.
Common Causes of Compile-Time Errors:
- Missing semicolon (;)
- Misspelled keywords (e.g., typing PRintf instead of printf)
- Missing or mismatched curly braces {}
- Missing commas or operators
- Missing double quotes in string literals
- Using undeclared variables
- Incorrect placement of statements (e.g., initializing a variable after a function call such as clrscr())
Example:
#include <stdio.h>
void main() {
int a, b
a = 10;
b = 20;
printf(“Sum = %d”, a + b);
}
Error: Missing semicolon after variable declaration (int a, b;)
2. Run-Time Errors:
If an error occurs while the program is running, it is called a run-time error.
These errors usually occur due to incorrect logic, invalid operations, or illegal use of memory.
Such errors are often difficult to detect before program execution.
Common Causes of Run-Time Errors:
- Array index out of range:
 Declaring an array of size 10 but trying to access the 15th element.
- Division by zero:
 Performing division when the denominator is zero.
- Invalid memory access:
 Referring to memory locations that do not exist.
- Incorrect data type operations:
 Assigning values that exceed the variable’s data type limit.
Example:
#include <stdio.h>
void main() {
int a = 10, b = 0;
int c = a / b; // Division by zero
printf(“Result = %d”, c);
}
Error: Division by zero (Run-Time Error)
- 
Warnings:
A warning is also an unusual condition that occurs during compilation, but it does not stop the execution of the program.
Instead, it alerts the programmer that something might lead to unexpected behavior.
Example:
#include <stdio.h>
void main() {
int x;
printf(“%d”, x); // Warning: ‘x’ is used uninitialized
}
Output: The program may still run, but the result is unpredictable.
Summary:
| Type of Error | When Detected | Effect | Example | 
| Compile-Time Error | During compilation | Stops the program from compiling successfully | Missing semicolon | 
| Run-Time Error | During execution | Stops the program while running | Division by zero | 
| Warning | During compilation | Does not stop execution, but may cause issues | Uninitialized variable usage | 
Conclusion:
Errors are a natural part of programming.
While compile-time errors can be easily identified and corrected by the compiler, run-time errors are more difficult to detect and may cause the program to crash.
To minimize such issues, programmers must carefully test, debug, and validate their code before execution.
Some More:
POP- Introduction to Programming Using ‘C’
OOP – Object Oriented Programming
DBMS – Database Management System
RDBMS – Relational Database Management System
Join Now: Data Warehousing and Data Mining