in Programming in C retagged
345 views
1 vote
1 vote

void main()

{

123e-23;

12334;

'A';
                                            no compiler error
"Abbdv";

}

void main

{                            

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

}

in Programming in C retagged
345 views

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