Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Conditional loop
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Examples== The following is a [[C (programming language)|C-style]] [[While loop]]. It continues looping while '''x''' does not equal '''3''', or in other words it only stops looping when '''x''' equals '''3'''. However, since '''x''' is initialized to '''0''' and the value of '''x''' is never changed in the loop, the loop will never end ([[infinite loop]]). <syntaxhighlight lang="c"> int x = 0; while (x != 3) { // code that doesn't change x } </syntaxhighlight> The while loop below will execute the code in the loop 5 times. '''x''' is initialized to 0, and each time in the loop the value of '''x''' is incremented. The while loop is set up to stop when '''x''' is equal to 5. <syntaxhighlight lang="c"> int x = 0; while (x != 5) { // code x += 1; } </syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)