Sample BASIC Program

Sample BASIC Program - Source Code

Our standard sample count-to-ten program in old-school BASIC:

10 REM  Sample BASIC Program - Counts To Ten
20 REM
30 REM  Copyright 2005 Andrew Eichstaedt
40 REM  Eichstaedt Development Group
50 REM  http://www.andrew-eichstaedt.com
60 REM
70 PRINT "Hello! I am a sample BASIC program"
80 PRINT "that counts to ten."
90 PRINT
100 FOR I=1 TO 10
110 PRINT I
120 NEXT I
130 PRINT
140 PRINT "Thanks for running me."
150 END

Historical Notes on BASIC Programming

Sample BASIC Program - BASIC LogoBASIC is of significant importance in the history of computing.

BASIC, which stands for "Beginner's All-purpose Symbolic Instruction Code," was originally designed in 1964 by John Kemeny and Thomas Kurtz at Dartmouth College. Its purpose was to allow students to program without the complexity of existing languages like FORTRAN II and ALGOL 60, upon which BASIC's design was partly based. Implemented as an interpreted language for student use on time-sharing systems, its design was that of a language prioritizing effectiveness as an educational tool over speed. The original BASIC programming manual from Dartmouth is available online.

BASIC in the 1970's became an important part of the personal computer revolution. Microsoft's BASIC interpreter for the Altair, one of the original personal computers for hobbiests, was one of the driving forces behind the Altair's sales. With the introduction of the Apple I and Apple II, Steve Wozniak's Integer BASIC made the machine an excellent tool for learning programming. In 1977, Applesoft BASIC, with support for floating point math, was licensed from Microsoft.

In the 1980's, BASIC became a staple programming language for home computers like the Commodore 64, VIC-20, Atari computers, the TI-99/4A, Timex-Sinclair 1000, and numerous others. BASIC was also included in ROM with the original IBM PCs and XTs.

Over time in the 1990's, BASIC developed further. Notable advances from Microsoft were Visual Basic, which provided a rapid application development environment (RAD) for the BASIC language. For more information, see the sample Visual BASIC program screenshot and additional information at Wikipedia. A variation called Visual Basic for Applications (VBA) allows users to program Microsoft Office applications like Access, Word, and Excel.

BASIC today has evolved into a family of modern, powerful dialects. The sample BASIC program above is written in a dialect similar to the original Dartmouth BASIC, and would be compatible with most 1980's personal computer and later BASIC implementations.

Sample BASIC Program - Comments for Programmers

BASIC is often, but not always, implemented as an interpreted language.

In most modern implementations of the language, line numbers are not required. However, in the original version and in classic 1980's personal computer versions, line numbers are necessary.

The first six lines of the program above are comments, beginning with REM for "Remark."

The following three PRINT statements simply print the quoted strings, line by line, to the screen (or in the original 1960's and early 1970's incarnations of the language, to the teletype).

The FOR loop in lines 100, 110, and 120, use a control structure resembling the FOR loop constructs of many other languages, repeating line 110 for successive values of the variable I from one to 10. This prints I line by line.

The two PRINT statements that follow, as before, simply print the indicated messages, and the END statement, as one would expect, marks the end of the program.

     
- -