user59714: 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>=0&&temp<=20)
{
digitalWrite(2,HIGH);
}
else if (temp>=20&&temp<=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.        

user2967: 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>=0&&temp<=20)
  {
    digitalWrite(2,HIGH);
  }
  else if (temp>=20&&temp<=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.

user16780: You don't want to stop the loop! You want it to run fast and often. 
Eventually you want it to not change the current state of a LED, but in your case, I rather do not see enough defined states of LEDs.

I want to first ON LED1 then ON LED2 then OFF LED1"

if then means an amount of time, remember that loop runs fast and does not take time by itself. You will have to notice the starting point in time and compare that with the current time and your desired intervals. (And you do not mention what should happen to LED2 after the second then )
const unsigned int LED1_DURATION=500;
const unsigned int LED3_DURATION=1000;
bool c2 = false;  // true while condition2 is met
unsigned long start2;  // time when condition2 starts 
void loop() {
  int temp = analogRead(A0); //read a temp value somehow 
  if(temp<=20)
  {
    digitlaWrite(1, LOW);
    digitalWrite(2,HIGH);
    digitlaWrite(3, LOW);
    c2 = false;
  }
  else if (temp >20 && temp <= 30)
  {
     digitalWrite(2, LOW);

     if (c2 == false) { c2 = true; start2=millis(); } // detect start time 

     if ((millis() - start2 < LED1_DURATION) ||
         (millis() - start2 > LED3_DURATION)   )
          digitalWrite(1,HIGH);
     else digitalWrite(1, LOW); 

     if ((millis() - start2 > LED1_DURATION) &&
         (millis() - start2 < LED3_DURATION)    )
          digitalWrite(3,HIGH);
     else digitalWrite(3,LOW);
  }
  else
  {
    digitlaWrite(1, LOW);
    digitalWrite(2, LOW);
    digitlaWrite(3, LOW);
    c2 = false;
  }
} 

This code contains a couple of guesses about states you did not mention, and a slightly different behavior (sorry), but I hope you get an idea...  

59714: <p>I am taking reading from temperature sensor and from that data. I have to control 3 LEDs. Lets consider LED1, LED2, LED3. </p>

<pre><code>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; 
</code></pre>

<p>my sketch is something like this:-</p>

<pre><code>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);
}
}
</code></pre>

<p>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.        </p>
 2967: <p>Your code doesn't make sense. You have a <code>while (1)</code> statement, which will run forever. Inside the body of that statement, you never change the value of <code>temp</code>.</p>

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

<pre><code>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);
  }
}   
</code></pre>

<p>With that loop function you would fetch a new value of temp on each pass through the loop, then decide what LEDs to light.</p>
 16780: <p>You don't want to stop the loop! You want it to run fast and often. </p>

<p>Eventually you want it to not change the current state of a LED, but in your case, I rather do not see enough defined states of LEDs.</p>

<blockquote>
  <p>I want to first ON LED1 then ON LED2 then OFF LED1"</p>
</blockquote>

<p>if <code>then</code> means an amount of time, remember that loop runs fast and does not take time by itself. You will have to notice the starting point in time and compare that with the current time and your desired intervals. (And you do not mention what should happen to LED2 after the second <em>then</em> )</p>

<pre><code>const unsigned int LED1_DURATION=500;
const unsigned int LED3_DURATION=1000;
bool c2 = false;  // true while condition2 is met
unsigned long start2;  // time when condition2 starts 
void loop() {
  int temp = analogRead(A0); //read a temp value somehow 
  if(temp&lt;=20)
  {
    digitlaWrite(1, LOW);
    digitalWrite(2,HIGH);
    digitlaWrite(3, LOW);
    c2 = false;
  }
  else if (temp &gt;20 &amp;&amp; temp &lt;= 30)
  {
     digitalWrite(2, LOW);

     if (c2 == false) { c2 = true; start2=millis(); } // detect start time 

     if ((millis() - start2 &lt; LED1_DURATION) ||
         (millis() - start2 &gt; LED3_DURATION)   )
          digitalWrite(1,HIGH);
     else digitalWrite(1, LOW); 

     if ((millis() - start2 &gt; LED1_DURATION) &amp;&amp;
         (millis() - start2 &lt; LED3_DURATION)    )
          digitalWrite(3,HIGH);
     else digitalWrite(3,LOW);
  }
  else
  {
    digitlaWrite(1, LOW);
    digitalWrite(2, LOW);
    digitlaWrite(3, LOW);
    c2 = false;
  }
} 
</code></pre>

<p>This code contains a couple of guesses about states you did not mention, and a slightly different behavior (sorry), but I hope you get an idea...  </p>
