Syntax:
(click image to view)
Description of parameters:
- init - used to set a counter.
- condition - evaluated for each loop iteration. If it evaluate to true, the loops will continue. Otherwise, the loops will end.
- increment - used to increment the counter.
(click image to view)
############################################################
The Output:
The number is 1
The number is 2
The number is 3
############################################################
The foreach Loop
Syntax:
(click image to view)
The example below shows a loop that will print the values of the given array:
(click image to view)
############################################################
The Output:
satu
dua
tiga
############################################################
No comments:
Post a Comment