user11493: In the first program after removing hand from the button it keeps on, means it keeps applying what is in the loop:
int led = 13;
int button = 12;
void setup() {
  pinMode(led, OUTPUT);
  pinMode(button, INPUT);
             }
void loop() {
  if (digitalRead(button) == HIGH)
  {
    digitalWrite(led, HIGH);
  }
             }

while in the second one it needs to press the button every time in order to apply what is in the loop,means to flash in this case, 
int led = 13;
int button = 12;
void setup() {
  pinMode(led, OUTPUT);
  pinMode(button, INPUT);
            }
void loop() {
  if (digitalRead(button) == HIGH)
  {
    digitalWrite(led, HIGH);
    delay(1000);
    digitalWrite(led, LOW);
    delay(1000);
  }
           }

Why different behavior although the same structure?
The problem is illustrated in this video :
https://www.youtube.com/watch?v=u5WGvKwJYFY&t=2s

user6628: This iteration of your code is better.  Now, the difference in behavior is that nothing in the first code ever executes digitalWrite(led, LOW);, while each iteration though the second code does.  Therefore the LED remains on forever in code 1, and depends on the button press in code two.   
If the behavior you desire is that the code remembers if the button has ever been pressed, latch that event in some state variable, and then in loop(), act on the value of the state variable:
int led = 13;
int button = 12;
int everHit = 0;
void setup() {
  pinMode(led, OUTPUT);
  pinMode(button, INPUT);
}

void loop() {
  if (digitalRead(button) == HIGH) everHit = 1;
  if (everHit) {
    digitalWrite(led, HIGH);
    delay(1000);
    digitalWrite(led, LOW);
    delay(1000);
  }
}


user-1: You read value only once ... what do you expected?
In the first sketch, you put the LED ON and never turn it OFF, no matter what.
In the second sketch, you put the LED ON and one second later you turned it OFF. As the value doesn't change, it keeps repeating.
You mistake: you read the button in setup. You have to read in each loop iteration.
void loop() {
  value = digitalRead(button);
  if (value == HIGH)
  {
    digitalWrite(led, HIGH);
    delay(1000);
    digitalWrite(led, LOW);
    delay(1000);
  }


11493: <p>In the first program after removing hand from the button it keeps on, means it keeps applying what is in the loop:</p>



<pre class="lang-cpp prettyprint-override"><code>int led = 13;
int button = 12;
void setup() {
  pinMode(led, OUTPUT);
  pinMode(button, INPUT);
             }
void loop() {
  if (digitalRead(button) == HIGH)
  {
    digitalWrite(led, HIGH);
  }
             }
</code></pre>

<p>while in the second one it needs to press the button every time in order to apply what is in the loop,means to flash in this case, </p>

<pre class="lang-cpp prettyprint-override"><code>int led = 13;
int button = 12;
void setup() {
  pinMode(led, OUTPUT);
  pinMode(button, INPUT);
            }
void loop() {
  if (digitalRead(button) == HIGH)
  {
    digitalWrite(led, HIGH);
    delay(1000);
    digitalWrite(led, LOW);
    delay(1000);
  }
           }
</code></pre>

<p>Why different behavior although the same structure?</p>

<p>The problem is illustrated in this video :
<a href="https://www.youtube.com/watch?v=u5WGvKwJYFY&amp;t=2s" rel="nofollow noreferrer">https://www.youtube.com/watch?v=u5WGvKwJYFY&amp;t=2s</a></p>
 6628: <p>This iteration of your code is better.  Now, the difference in behavior is that nothing in the first code ever executes <code>digitalWrite(led, LOW);</code>, while each iteration though the second code does.  Therefore the LED remains on forever in code 1, and depends on the button press in code two.   </p>

<p>If the behavior you desire is that the code remembers if the button has ever been pressed, latch that event in some state variable, and then in <code>loop()</code>, act on the value of the state variable:</p>

<pre><code>int led = 13;
int button = 12;
int everHit = 0;
void setup() {
  pinMode(led, OUTPUT);
  pinMode(button, INPUT);
}

void loop() {
  if (digitalRead(button) == HIGH) everHit = 1;
  if (everHit) {
    digitalWrite(led, HIGH);
    delay(1000);
    digitalWrite(led, LOW);
    delay(1000);
  }
}
</code></pre>
 -1: <p>You read <code>value</code> only once ... what do you expected?</p>

<p>In the first sketch, you put the LED ON and never turn it OFF, no matter what.</p>

<p>In the second sketch, you put the LED ON and one second later you turned it OFF. As the <code>value</code> doesn't change, it keeps repeating.</p>

<p>You mistake: you read the button in <code>setup</code>. You have to read in each <code>loop</code> iteration.</p>

<pre><code>void loop() {
  value = digitalRead(button);
  if (value == HIGH)
  {
    digitalWrite(led, HIGH);
    delay(1000);
    digitalWrite(led, LOW);
    delay(1000);
  }
</code></pre>
