Please Give The Examples Of Semantic And Syntax Errors In C Language?

Asked By 0 points N/A Posted on -
qa-featured

Hi everyone,

I have just started to learn programming and a kind of confused in semantic and syntax errors. Please provide me some examples to explain both the types of errors.

SHARE
Answered By 0 points N/A #304843

Please Give The Examples Of Semantic And Syntax Errors In C Language?

qa-featured

The basic difference between the semantic and syntax error is that, the semantic error occurs when there is fault in your “logic “whereas the syntax error occurs when there is error in the syntax of the sequence of character written.
Some of them are given below:
Semantic error
• Area of rectangle= length + breadth // the formula to find the area for rectangle is l*b
• 1/0
• If(a=b) // here you are assigning it not comparing
• x-=1 // add one to x

Syntax error
• #include // can’t give space between the #include and the angular braces
• printf(“hello”) // no ; after the printf statement
• scanf(“%d”, x); // not putting ampersand before the variable while using scanf

• if ()
{
{
}
// no closing all the curly brackets properly.

Related Questions