STRUCTURAL CONTROL continuation STATEMENT SWITCH WHILE DO WHILE
- Slides: 20
STRUCTURAL CONTROL continuation STATEMENT �SWITCH �WHILE �DO. . WHILE
Statement swith
�Used to test an expression to perform a number of different actions. �Usually used in place of a statement if. . . elseif . . . else.
Statement switch Sintaks : Switch (ekspresi) { case (kondisi 1): blok pernyataan 1; break; case (kondisi 2): blok pernyataan 2; break; . . case (kondisi N): blok pernyataan N; break; deafault: blok pernyataan lainnya; break; }
Sintaks statement switch Sintaks 2 : Switch (ekspresi) : case (kondisi 1) : blok pernyataan 1; break; case (kondisi 2) : blok pernyataan 2; break; . . case (kondisi. N) : blok pernyataan. N; break; default: blok pernyataan lainnya; break; endswitch;
Example <html> <head> <title> statement switch </title> </head> <body> <? php $Kode = date ("m"); switch($Kode) { case "01" : case "02" : case "03" : case "04" : case "05" : case "06" : case "07" : case "08" : case "09" : $Month = "January"; break; case "10" : $Month = "February"; break; case "11" : $Month = "March"; break; case "12" : $Month = "April"; break; $Month = "May"; break; $Month = "June"; break; $Month = "July"; break; $Month = "August"; break; $Month = "September"; break; $Month = "October"; break; $Month = "November"; break; $Month = "December"; break; } print ("Kode = $Kode "); print ("Nama Bulan = $Month "); ? > </body> </html>
Statement While
Statement used to evaluate looping statement block for condition is true, and it will stop when the condition is false
Sintaks : While (kondisi) { blok pernyataan; } Atau While (kondisi) : blok pernyataan; endwhile
�The condition is a boolean expression �Block statement is a list of statements to be repeated as long as conditions are met. �If the start condition is false, the statement block will never be done.
Example <html> <head> <title>statement swile</title> </head> <body> <? php print ("<u> cara pertama : </u> "); $x = 1; while ($x <=5) { print ("x = $x "); $x++; } print ( "<u> cara kedua: </u> "); $x = 1; while ($x<=5): print ("x = $x "); $x++; endwhile; ? > </body> </html>
Result for while
Statement do. . . while
�In principle, the statement is similar to while working �In the do. . while, block statements certainly done time and then do the test conditions. �If the condition is still true, the statement block reworked. �If the condition is false, the loop stops.
Sintaks : Do { blok pernyataan; } While (kondisi);
�Condition is boolean �Block statements are statements that are repeated throughout the list true condition, �If the condition is false, then we are out of the statement and the statement after the while working.
example <html> <head> <title> statement dowhile </title> </head> <body> <? php $hitung = 1; print ("Mulai. . . "); print ("Sekarang Hitung = $hitung "); do { print ("Indonesia Malaysia Cambodjia "); $hitung++; } while ($hitung <=5); print ("SELESAI. "); print ("Sekarang Hitung = $hitung "); ? > </body> </html>
Result for dowhile
The meeting is finished, you can download these materials at www. stmik-tasikmalaya. ac. id, download the menu, the course material ( filename = PHPMy. SQL 4, Kamboja. ) thank you see you at the next meeting
- Byzantine empire flocabulary
- Continuation passing style
- Continuation writing
- Linking words to express consequence
- Consequence linking words
- Continuation project proposal
- Spitnaz
- Jcl continuation
- Clos criteria formula
- Go switch limit switch
- Multiple selection statement
- Switch multiple-selection statement
- What are switch statements in c
- C++ switch
- Switch in pseudocode
- Mips jump table
- A "switch" statement is used to *
- Switch statement in c
- Access switch statement
- While do loop
- Struktur kontrol sequence