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
Dartmouth BASIC
(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!
==BASIC language== The first release implemented the following statement types, taking some of its operators and keywords from [[FORTRAN|FORTRAN II]] and some from [[ALGOL|ALGOL 60]]. Overall, the language more closely follows the FORTRAN model,{{sfn|Kurtz|1981|p=523}} in that it generally has one statement per line of code, lacks ALGOL's "blocks" to group code (these [[structured programming]] constructs were a primary reason for ALGOLs development) and the use of GOTO to control program flow. From ALGOL it took the <code>FOR...TO...STEP</code> style loops that replaced FORTRAN's unwieldy <code>DO...CONTINUE</code> statements.{{sfn|Kurtz|1981|p=524}} BASIC also simplified the <code>IF...THEN</code> construct to allow simple comparisons like {{code|IF X>5 THEN GOTO 20|basic}}, as opposed to FORTRAN's <code>IF (X-5) 20,20,30</code>.{{sfn|Kurtz|1981|p=524}} FORTRAN's style "computed IF" was reintroduced with the <code>ON...GOTO</code> command in later versions. Variable names were limited to A to Z, A0 to A9, B0 to B9, ..., Z0 to Z9, giving a maximum of 286 possible distinct variables. FORTRAN's odd system for setting up the variables I through N as integers and the rest as floating point was removed, and all variables were assumed to be floating point and dimensioned with up to 10 elements. The <code>DIM</code> command was only required if the array held more than ten elements.{{sfn|Kurtz|1981|p=524}} Array names were restricted to A to Z only. ===List of BASIC statements=== ; <code>DEF</code> : define single line functions ; <code>DIM</code> : (short for ''dimension'') define the size of arrays ; <code>END</code> : define the end of the program ; <code>STOP</code> : stop a program before the textual end ; <code>[[For loop|FOR]] / TO / STEP</code> : define loops ; <code>NEXT</code> : mark the end of loops ; <code>[[GOSUB]]</code> : transfer control to simple subroutines ; <code>[[Return statement|RETURN]]</code> : return control from simple subroutines ; <code>[[GOTO]]</code> : transfer control to another statement ; <code>IF / THEN</code> : decision making ; <code>LET / =</code> : assign formula results to a variable ; <code>PRINT</code> : output results ; <code>DATA</code> : store static data within the program ; <code>READ</code> : input data stored in DATA statements ; <code>REM</code> : comment ("REMark") It also implemented floating-point numeric variables and arithmetic. ===List of operators=== {|class="wikitable" |- !colspan="2"|Arithmetic operators !colspan="2"|Relational/logical operators |- |style="vertical-align: top"|<code>-</code> |style="vertical-align: top"|Negation (unary op.) |style="vertical-align: top"|<code>=</code> |style="vertical-align: top"|Equal To |- |style="vertical-align: top"|<code>+</code> |style="vertical-align: top"|Addition |style="vertical-align: top"|<code><></code> |style="vertical-align: top"|Not Equal To |- |style="vertical-align: top"|<code>-</code> |style="vertical-align: top"|Subtraction (binary op.) |style="vertical-align: top"|<code><</code> |style="vertical-align: top"|Less Than |- |style="vertical-align: top"|<code>*</code> |style="vertical-align: top"|Multiplication |style="vertical-align: top"|<code><=</code> |style="vertical-align: top"|Less Than or Equal To |- |style="vertical-align: top"|<code>/</code> |style="vertical-align: top"|Division |style="vertical-align: top"|<code>></code> |style="vertical-align: top"|Greater Than |- |style="vertical-align: top"|<code>?</code> |style="vertical-align: top"|Exponentiation |style="vertical-align: top"|<code>=></code> |style="vertical-align: top"|Greater Than or Equal To |- !colspan="4"|Grouping operator |- |style="vertical-align: top"|<code>( )</code> |colspan="3" style="vertical-align: top"|Grouping |} ===List of functions=== ; <code>ABS</code> : Absolute value ; <code>ATN</code> : Arctangent value (result in [[radian]]s) ; <code>COS</code> : Cosine value (argument in [[radian]]s) ; <code>EXP</code> : Exponential value ; <code>INT</code> : Integer value ; <code>LOG</code> : Natural Logarithmic value ; <code>RND</code> : Random value ; <code>SIN</code> : Sine value (argument in [[radian]]s) ; <code>SQR</code> : Square root value ; <code>TAN</code> : Tangent value (argument in [[radian]]s)
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)