Syntax for stopping loop until the condition has made false I am taking reading from temperature sensor and from that data. I have to control 3 LEDs. Lets consider LED1, LED2, LED3. 

If temperature range between 0-20
   I have to HIGH LED2.
   else if temperature range between 20-30 
I have to HIGH LED1; HIGH LED3; LOW LED1; 


my sketch is something like this:-

while(1)
{
if(temp&gt;=0&amp;&amp;temp&lt;=20)
{
digitalWrite(2,HIGH);
}
else if (temp&gt;=20&amp;&amp;temp&lt;=30)
{
digitalWrite(1,HIGH);
digitalWrite(3,HIGH);
digitalWrite(1,LOW);
}
}


The problem which I am facing is LED1 is continuously ON (which should be OFF), when temperature is between 20-30 because of continuously running loop so, how can I stop loop, once the statement under second condition has executed till the second condition has made false.
Your code doesn't make sense. You have a while (1) statement, which will run forever. Inside the body of that statement, you never change the value of temp.

An Arduino sketch's loop() function runs continuously. You should not have a while (1) loop inside your loop function. You should have a loop function something like this:

void loop() {
  temp = //read a temp value somehow 
  if(temp&gt;=0&amp;&amp;temp&lt;=20)
  {
    digitalWrite(2,HIGH);
  }
  else if (temp&gt;=20&amp;&amp;temp&lt;=30)
  {
    digitalWrite(1,HIGH);
    digitalWrite(3,HIGH);
    digitalWrite(1,LOW);
  }
}   


With that loop function you would fetch a new value of temp on each pass through the loop, then decide what LEDs to light.