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
Control flow
(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!
== Control structures in practice == Most programming languages with control structures have an initial keyword which indicates the type of control structure involved.{{clarify|date=November 2015}} Languages then divide as to whether or not control structures have a final keyword. * No final keyword: [[ALGOL 60]], [[C (programming language)|C]], [[C++]], [[Go (programming language)|Go]], [[Haskell]], [[Java (programming language)|Java]], [[Pascal (programming language)|Pascal]], [[Perl]], [[PHP]], [[PL/I]], [[Python (programming language)|Python]], [[PowerShell]]. Such languages need some way of grouping statements together: ** ALGOL 60 and Pascal: <code>begin</code> ... <code>end</code> ** C, C++, Go, Java, Perl, PHP, and PowerShell: [[Curly bracket programming language|curly brackets]] <code>{</code> ... <code>}</code> ** PL/I: <code>DO</code> ... <code>END</code> ** Python: uses [[Indent style|indent]] level (see [[Off-side rule]]) ** Haskell: either [[Indent style|indent]] level or curly brackets can be used, and they can be freely mixed ** Lua: uses <code>do</code> ... <code>end</code> * Final keyword: [[Ada (programming language)|Ada]], [[APL (programming language)|APL]], [[ALGOL 68]], [[Modula-2]], [[Fortran 77]], [[Mythryl]], [[Visual Basic]]. The forms of the final keyword vary: ** Ada: final keyword is <code>end</code> + ''space'' + initial keyword e.g., <code>if</code> ... <code>end if</code>, <code>loop</code> ... <code>end loop</code> ** APL: final keyword is <code>:End</code> optionally + initial keyword, e.g., <code>:If</code> ... <code>:End</code> or <code>:If</code> ... <code>:EndIf</code>, <code>Select</code> ... <code>:End</code> or <code>:Select</code> ... <code>:EndSelect</code>, however, if adding an end condition, the end keyword becomes <code>:Until</code> ** ALGOL 68, Mythryl: initial keyword spelled backwards e.g., <code>if</code> ... <code>fi</code>, <code>case</code> ... <code>esac</code> ** Fortran 77: final keyword is <code>END</code> + initial keyword e.g., <code>IF</code> ... <code>ENDIF</code>, <code>DO</code> ... <code>ENDDO</code> ** Modula-2: same final keyword <code>END</code> for everything ** Visual Basic: every control structure has its own keyword. <code>If</code> ... <code>End If</code>; <code>For</code> ... <code>Next</code>; <code>Do</code> ... <code>Loop</code>; <code>While</code> ... <code>Wend</code>
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)