types of error explain with example Related: Short & Long Answer Ques...
Types of errors :-
1.systematic errors
2.Random errors
3.gross errors
(a).systematic error
1.instrumental errors
2.imperfaction in experimental technique or procedure
3.persanal error
4.error due to external effort
5.least count error
types of error explain with example Related: Short & Long Answer Ques...
There are several types of errors that can occur in various fields. Here are a few common types of errors and their explanations:
1. Syntax Error: This error occurs when the code violates the rules of the programming language. It is usually detected by the compiler or interpreter during the compilation or interpretation process. For example, in Python, if you forget to close a parenthesis or use a wrong keyword, it will result in a syntax error.
Example:
```python
# Syntax error - missing closing parenthesis
print("Hello, World!"
```
2. Runtime Error: This error occurs during the execution of a program. It happens when the code runs into unexpected situations that it cannot handle. Runtime errors can include division by zero, accessing an out-of-bounds array index, or attempting to open a file that doesn't exist.
Example:
```python
# Runtime error - division by zero
numerator = 10
denominator = 0
result = numerator / denominator
```
3. Logic Error: This error occurs when the code does not produce the expected output due to a mistake in the logic or algorithm. It is usually caused by incorrect implementation or understanding of the problem. Logic errors can be challenging to identify and resolve since the code may run without any error messages.
Example:
```python
# Logic error - incorrect calculation
radius = 5
area = 2 * 3.14 * radius # Incorrect formula for calculating the area of a circle
```
4. Semantic Error: This error occurs when the code is logically correct and follows the syntax rules but does not produce the desired result. It is often caused by a misunderstanding of the problem requirements or incorrect assumptions made in the code. Semantic errors can be difficult to detect since the code appears to run without any issues.
Example:
```python
# Semantic error - incorrect variable assignment
age = "25"
age += 1 # Trying to add a number to a string variable
```
It is important to identify and fix errors in code to ensure the program functions as intended. Debugging techniques and tools can be utilized to trace and resolve these errors.
To make sure you are not studying endlessly, EduRev has designed Class 11 study material, with Structured Courses, Videos, & Test Series. Plus get personalized analysis, doubt solving and improvement plans to achieve a great score in Class 11.