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
Line number
(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!
==Line numbers and GOTOs== In "unstructured" programming languages such as [[BASIC]], line numbers were used to specify the targets of [[branch (computer science)|branching statements]]. For example: <syntaxhighlight lang="basic"> 1 S=0: N=-1 2 INPUT "ENTER A NUMBER TO ADD, OR 0 TO END"; I 3 S=S+I: N=N+1: IF I<>0 THEN GOTO 2 4 PRINT "SUM="; S: PRINT "AVERAGE="; S/N </syntaxhighlight> [[GOTO]]-style branching can lead to the development of [[spaghetti code]]. (See [[Considered harmful]], [[Structured programming]].) Even in some later versions of BASIC that still mandated line numbers, the use of line number-controlled GOTOs was phased out whenever possible in favor of cleaner constructs such as the [[for loop]] and [[while loop]]. Many modern languages (including [[C (programming language)|C]] and [[C++]]) include a version of the GOTO statement; however, in these languages the target of a GOTO is specified by a [[line label]] instead of a line number.
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)