Else has an if but compiler says it doesn't

Hi.
I was trying to write some short code in my free time , but I faced a weird problem .

/* Made by Arman on  23 / APRIL / 2015 
*/
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2);  // LCD is declared

void setup()
{
  lcd.init();   // LCD's initialization 
  lcd.backlight(); // backlight  
  lcd.clear(); // clear shit
  if (random(2,5) == 3); {
    lcd.print("It will ");
  }
  else {
    lcd.print("It won't ");
  }
  delay(1000); //makes things more stressful
  setCursor(0,1);
  // writes the first line
  if (random(10,27) == 13); {
    lcd.print("stop happening.");
  }
  else {
    lcd.print("happen.");
  }
 // writes the second line
 
}
void loop () {
}

Then a weird error appears (a bunch of them) :

sketch_apr23a.ino: In function 'void setup()':
sketch_apr23a:18: error: 'else' without a previous 'if'
sketch_apr23a:22: error: 'setCursor' was not declared in this scope
sketch_apr23a:24: error: expected `;' before 'if'
sketch_apr23a:27: error: 'else' without a previous 'if'

Else without previous if ?
I know I should put
If - else If - else
but I don't need else If .

setCursor wasn't declared ?
I tried setCursor(0,1);
and setCursor(0,1)
(without semicolon) but no difference .

expected ; before if ?
Where did I miss THAT ?

Thanks in advance .

The compiler is correct, the else is effectively in the middle of nowhere:

if (random(2,5) == 3)[glow=red,2,300][tt][b][size=x-large];[/size][/b][/glow] {
lcd.print("It will ");
}
else {
lcd.print("It won't ");
}[/tt]

if (random(10,27) == 13); {        
    lcd.print("stop happening.");
  }

the same mistake here

Your if's have an empty statement as the then-part. The empty statement is ";".
If takes either a statement or a block, you gave an empty statement so the brace
starts a new block unrelated to the if.

Arman5592:
Else without previous if ?

Obviously.

Here is your code with slightly different formatting and comments added:

if (random(2,5) == 3); // if (random(2,5) == 3) ==> do nothing, if-statement finished
{                                // begin a code block 
    lcd.print("It will ");
}                                // end a code block
else                            // else without prevous if!
{
    lcd.print("It won't ");
}

Your title suggests that you think the compiler is making a mistake.

NEVER waste time worrying about compiler bugs. They are only a little more common than hens' teeth.

ALWAYS assume the compiler is correct and the error is in your own code.

...R

Robin2:
Your title suggests that you think the compiler is making a mistake.

NEVER waste time worrying about compiler bugs. They are only a little more common than hens' teeth.

ALWAYS assume the compiler is correct and the error is in your own code.

...R

Robin2:
Your title suggests that you think the compiler is making a mistake.

NEVER waste time worrying about compiler bugs. They are only a little more common than hens' teeth.

ALWAYS assume the compiler is correct and the error is in your own code.

...R

I know this algorithm wouldn't fail but I didn't know what was wrong .

Thanks everyone , problem is solved .
I also missed lcd. before setCursor .
This is the working one :

/* Made by Arman on  23 / APRIL / 2015 
*/
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2);  // LCD is declared

void setup()
{
  lcd.init();   // LCD's initialization 
  lcd.backlight(); // backlight  
  lcd.clear(); // clear shit
  if (random(2,5) == 3) {
    lcd.print("It will ");
  }
  else {
    lcd.print("It won't ");
  }
  delay(1000); //makes things more stressful
  lcd.setCursor(0,1);
  // writes the first line
  if (random(10,27) == 13) {
    lcd.print("stop happening.");
  }
  else {
    lcd.print("happen.");
  }
 // writes the second line
 
}
void loop () {
}