Loop structures: Difference between revisions
Content added Content deleted
(AppleScript: repeat-until) |
(Added C section) |
||
Line 10: | Line 10: | ||
--endless loop |
--endless loop |
||
end repeat |
end repeat |
||
==[[C]]== |
|||
[[Category:C]] |
|||
===while=== |
|||
'''Compiler:''' [[GCC]] 4.1.2 |
|||
int main (int argc, char ** argv) { |
|||
int condition = 1; |
|||
while ( condition ) { |
|||
// Do something |
|||
// Don't forget to change the value of condition. |
|||
// If it remains nonzero, we'll have an infinite loop. |
|||
} |
|||
} |
|||
===do-while=== |
|||
'''Compiler:''' [[GCC]] 4.1.2 |
|||
int main (void) { |
|||
int condition = 1; |
|||
do { |
|||
// Do something |
|||
// Don't forget to change the value of condition. |
|||
// If it remains nonzero, we'll have an infinite loop. |
|||
} while ( condition ); |
|||
} |
Revision as of 16:03, 25 January 2007
AppleScript
repeat-until
set i to 5 repeat until i is less than 0 set i to i - 1 end repeat
repeat --endless loop end repeat
C
while
Compiler: GCC 4.1.2
int main (int argc, char ** argv) { int condition = 1; while ( condition ) { // Do something // Don't forget to change the value of condition. // If it remains nonzero, we'll have an infinite loop. } }
do-while
Compiler: GCC 4.1.2
int main (void) { int condition = 1; do { // Do something // Don't forget to change the value of condition. // If it remains nonzero, we'll have an infinite loop. } while ( condition ); }