πŸŽ“ Computer Science & Engineering Portal

Master Engineering Disciplines with Structured Notes

Comprehensive academic lecture notes, exam-oriented unit summaries, laboratory manuals, and previous year question papers designed strictly for university students.

πŸ“‘

University Syllabi

AKTU & AICTE aligned semester guidelines.

πŸ“

Exam Question Papers

Previous 5 years solved university papers.

πŸ’‘

Lab Manuals & Viva

Practical codes with outputs & interview Qs.

Core Subjects & Units Hub

Click on any specific unit to immediately view its lecture notes below

Viewing All Lectures

Semantic Error

Semantic Error

During the semantic analysis phase, this type of error appears. These types of error are detected at compile time.

Most of the compile time errors are scope and declaration error. For example: undeclared or multiple declared identifiers. Type mismatched is another compile time error.

The semantic error can arises using the wrong variable or using wrong operator or doing operation in wrong order.

Some semantic error can be:

  • Incompatible types of operands
  • Undeclared variable
  • Not matching of actual argument with formal argument

Example 1: Use of a non-initialized variable:

  1. int i;  
  2. void f (int m)   
  3. {  
  4.       m=t;  
  5. }  

In this code, t is undeclared that's why it shows the semantic error.

Example 2: Type incompatibility:

  1. int a = "hello";      // the types String and int are not compatible  

Example 3: Errors in expressions:

  1. String s = "...";  
  2. int a = 5 - s;     // the - operator does not support arguments of type String  

Labels: ,

Discussion & Queries (<$I18NNumComments$>):

<$CommentPager$>
<$I18NAtCommentTimeWithPermalink$>, <$I18NCommentAuthorSaid$>

<$BlogCommentBody$>

<$BlogCommentDeleteIcon$>
<$CommentPager$>