The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
0 votes
76 views
int main(void) {
in/*comment x;
floa/*comment*/t gate;
return 0;
}

Which type of error here?

A)Semantic Error
B)Syntax Error
C)Both
D)None
asked in Compiler Design by (253 points) | 76 views
+1
none. since comment starts with /* and ends with */

it will be int gate;
0
But it shows error on IDE
0
prog.c: In function 'main':
The error on IDE-
prog.c:5:5: error: unknown type name 'in'
     in/*comment x; 
     ^
prog.c:6:22: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'gate'
     floa/*comment*/t gate;
+1
lexical error for in/*
0
How so?
+1
It will be a syntax error.
+1
@Shubhanshu

what about in
+1
but in general, lexical analyzer will remove the comments and blank spaces right? so the comment should be vanished when the code reaches syntax analyzer.
+1
Oops mistyped it is a semantic error, not a syntax error.
0
Actually in class,key given by sir is C i.e. both.. but I am not able to get it
+1

@Reshu $ingh what is the solution provided by them?

0

@Shubhanshu

When "in" is read and since comment in between so "in" and "t" two different leximes and "in" and "t" without comma-- So SYNTAX error

Now 'gate' variable has come but without data type being defined -- So SEMANTIC error

 

+1
1st line not a comment line

Please log in or register to answer this question.

Related questions

0 votes
1 answer
4
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
49,811 questions
54,540 answers
188,429 comments
75,596 users