if ( year % 4 == 0 )
int i = 0;
else
int j = 0;
The syntax errors which crop up in eclipse due to this line of code are:
- Syntax error on token "int", delete this token
- i cannot be resolved to a variable
- Syntax error on token "int", delete this token
- j cannot be resolved to a variable
- Syntax error on token "=", delete this token
I have no clue why this is happening.
From what I have observed, I think putting an int declaration in the if else construct body is making it happen.
If i declare i and j earlier in the code and the run the program then the error vanishes like:
int i; int j;
if ( year % 4 == 0 )
i = 0;
else
j = 0;
No syntax error in this case. Why?