there is an expected unqualified id bofore "else"(last else) .pls help!!

// error is
Arduino: 1.6.5 (Windows Vista), Board: “Arduino/Genuino Uno”

hot_cold_ultrasonic:24: error: expected unqualified-id before ‘else’
hot_cold_ultrasonic:28: error: expected unqualified-id before ‘if’
hot_cold_ultrasonic:33: error: expected unqualified-id before ‘else’
hot_cold_ultrasonic:36: error: expected unqualified-id before ‘else’
expected unqualified-id before ‘else’

This report would have more information with
“Show verbose output during compilation”
enabled in File > Preferences.

int SensorPin=7;
int RedLedPin=5;
int BlueLedPin=6;
int RedValue;

int distance;
unsigned long pulseDuration=0;
void setup() {}
void loop(){
pinMode(SensorPin,OUTPUT);
digitalWrite(SensorPin,HIGH);
delayMicroseconds(5);
digitalWrite(SensorPin,LOW);
pinMode(SensorPin,INPUT);
pulseDuration=pulseIn(SensorPin,HIGH);
pulseDuration=pulseDuration/2;
distance=int(pulseDuration/29);
if (distance > 0 && distance < 25)

int RedValue=(25-distance)*10.2;

analogWrite(RedLedPin, RedValue);
}
else
{
analogWrite(RedLedPin, 0);
}
if (distance > 10 && distance <= 25)
{
int BlueValue = (distance-10)*17;
analogWrite(BlueLedPin, BlueValue);
}
else if (distance > 25 && distance < 50)
{
int BlueValue = (50-distance)*10.2;
} else //error in line pls help!!
{
analogWrite(BlueLedPin, 0);

}

It appears you have an opening and closing brace mismatch.

    if (distance > 0 && distance < 25)
 // no opening brace here
      int RedValue=(25-distance)*10.2;

    analogWrite(RedLedPin, RedValue);
   } // so this brace is out of place
   else
   {
 analogWrite(RedLedPin, 0);
 }

Gopalakrish07200:

void loop(){

pinMode(SensorPin,OUTPUT);
  digitalWrite(SensorPin,HIGH);
  delayMicroseconds(5);
  digitalWrite(SensorPin,LOW);
  pinMode(SensorPin,INPUT);
  pulseDuration=pulseIn(SensorPin,HIGH);
    pulseDuration=pulseDuration/2;
    distance=int(pulseDuration/29);
    if (distance > 0 && distance < 25)

You need an opening curly brace “{” here.
Please always post your code using code tags ( the “</>” above the posting window).
Hitting Ctrl +T (Auto format) in the IDE would have shown your error immediately.

And why:

 pulseDuration=pulseDuration/2;
    distance=int(pulseDuration/29);

when:

   distance=int(pulseDuration/58);

does the same thing in only one line?

   } // so this brace is out of place

That depends on your definition of "out of place". Being where it is, it terminates the loop() function.

All the rest of the code, then, is not in a function, which causes the compiler all kinds of grief.

A better term would have been "orphaned". The OP needed to add another brace at the start of the "if".