retagged
346 views
1 votes
1 votes

void main()

{

123e-23;

12334;

'A';
                                            no compiler error
"Abbdv";

}

void main

{                            

{'A','b','b','d','v','\0'};
                                                        compiler error
{1,2,3,4}; 

}

retagged

1 Answer

0 votes
0 votes

It is considering

{'A','b','b','d','v','\0'};

as separate code block  or you can say separate scope because it is enclosed within two curly braces.

Having said that, consider the below line :

'A','b','b','d','v','\0'

The above line is being treated as a one line statement, much like 

int i

As you terminate a statement with a semicolon, it is required in the code provided by you too. So, you make it 

'A','b','b','d','v','\0';

You do the same with the next line too and make it as 

1,2,3,4;

It is interesting to note that the semicolon after the closing curly brace i.e. after the } is not required so the below code will compile pretty well.

void main(){
{'A','b','b','d','v','\0';}
{1,2,3,4;}
}

Related questions

1 votes
1 votes
1 answer
1
Jason asked Mar 20, 2018
3,455 views
void main() { int total-value, Num=2,sum=5,var1; 5=Num; var1=2; sum=num*1; if(sum=var1) { sum=sum+1 } }Here, is $\text{"total-value"}$ a lexical error?
6 votes
6 votes
1 answer
2
junaid ahmad asked Jan 12, 2018
1,269 views
Is this line a/*b successfully generating the token's or it give lexical error ? if it is given the lexical error then why so ?I think it will give lexical error because...
7 votes
7 votes
4 answers
3
itsvkp1 asked Nov 1, 2017
3,265 views
if there is miss spelling in some keyword in a program then this misspelled keyword will be treated as lexical errors or it will be treated as a new identifier and accept...
2 votes
2 votes
1 answer
4
Manu Thakur asked Sep 26, 2017
1,568 views
This screenshot is token from the book Ullman,How can following be a lexical error? because "elipseSize" should have a token recorded as an identifier.