IF
Jeśli warunek został spełniony wykonaj to co jest w klamrach. Istnieje możliwość stosowania operatorów logicznych i można łączyć warunki.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(warunek) | |
{ | |
intrukcje | |
} | |
LUB | |
if(warunek) | |
instrukcja; |
ELSE
Jeśli warunek nie jest spełniony wykonaj to co w klamrach.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(warunek) | |
{ | |
instrukcje spełniony warunek | |
}else | |
{ | |
instrukcje niespełniony warunek | |
} |
ELSE IF
Jeśli warunek jest spełniony wykonaj to co w klamrach, jeśli nie sprawdź warunek 2, jeśli spełnia to wykonaj instrukcje w klamrach itd.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (warunek1) { | |
instrukcje1; | |
} | |
else if (warunek2) { | |
instrukcje2; | |
} | |
..... | |
else if (warunekN) { | |
instrukcjeN; | |
} | |
else { | |
instrukcjeM; | |
} |
SWITCH
Jest to tak jakby wielokrotny "IF" w którym określamy tylko jeden warunek.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
switch(wyrazenie) | |
{ | |
case wartosc1: | |
instrukcja1; | |
break; | |
... | |
case wartoscn: | |
instukcja2; | |
break; | |
} |
Brak komentarzy:
Prześlij komentarz