Selezione singola

Decidere se eseguire o meno una o più istruzioni

if

Dopo aver eseguito istruzione 0 decide se eseguire

  • Istruzione 11
  • Istruzione 12

e poi continua eseguendo istruzione 2.

Codifiche

Più istruzioniUna sola istruzione
 
...
SE (E = 1) ALLORA
  INIZIO
    Istr_11
    Istr_12
  FINE
...
...
SE (E = 1) ALLORA
    Istr_1
...
C…
...
if(E == 1)
{
   istr_11;
   istr_12;
}
...
...
if(E == 1)
   istr_1;
...
...
if(E == 1) istr_1;
...
LibreLogo
...
IF E == 1 [
    ISTR_11
    ISTR_12
]
...
...
IF E == 1 [
    ISTR_1
]
...
...
IF E == 1 [ ISTR_1 ]
...
Pascal
...
If E = 1 Then
   Begin
      Istr_11;
      Istr_12;
   End;
...
...
If E = 1 Then
   Istr_1;
...
...
If E = 1 Then Istr_1;
...
Python
...
if E == 1:
    istr_11
    istr_12
...
...
if E == 1:
   istr_1
...
...
if E == 1: istr_1
...
SMALL
BASIC
...
If E = 1 Then
   Istr_1
   Istr_2
EndIf
...
...
If E = 1 Then
   Istr_1
EndIf
...
VISUAL
BASIC
...
If E = 1 Then
   Istr_1
   Istr_2
End If
...
...
If E = 1 Then
   Istr_1
End If
...
...
If E = 1 Then Istr_1
...

Se viene controllata l’esecuzione di singole istruzioni si può semplificare la scrittura.
In Basic è possibile eliminare anche l’etichetta End If se si scrive l’unica istruzione controllata sulla stessa riga dell’If