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
For 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!
===1960: COBOL=== {{Further|COBOL}} [[COBOL]] was formalized in late 1959 and has had many elaborations. It uses the PERFORM verb which has many options. Originally all loops had to be out-of-line with the iterated code occupying a separate paragraph. Ignoring the need for declaring and initializing variables, the COBOL equivalent of a ''for''-loop would be. <syntaxhighlight lang="cobol"> PERFORM SQ-ROUTINE VARYING I FROM 1 BY 1 UNTIL I > 1000 SQ-ROUTINE ADD I**2 TO SUM-SQ. </syntaxhighlight> In the 1980s, the addition of in-line loops and ''[[structured programming]]'' statements such as END-PERFORM resulted in a ''for''-loop with a more familiar structure. <syntaxhighlight lang="cobol"> PERFORM VARYING I FROM 1 BY 1 UNTIL I > 1000 ADD I**2 TO SUM-SQ. END-PERFORM </syntaxhighlight> If the PERFORM verb has the optional clause TEST AFTER, the resulting loop is slightly different: the loop body is executed at least once, before any test.
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)