To prepare the program for input from the terminal during program execution.
INPUT[;][prompt string;] list of variablesINPUT[;][prompt string,] list of variables
prompt string is a request for data to be supplied during program execution.
list of variablescontains the variable(s) that stores the data in the prompt string.
Each data item in the prompt string must be surrounded by double quotation marks, followed by a semicolon or comma and the name of the variable to which it will be assigned. If more than one variable is given, data items must be separated by commas.
The data entered is assigned to the variable list. The number of data items supplied must be the same as the number of variables in the list.
The variable names in the list may be numeric or string variable names (including subscripted variables). The type of each data item input must agree with the type specified by the variable name.
Too many or too few data items, or the wrong type of values (for example, numeric instead of string), causes the message "?Redo from start" to be printed. No assignment of input values is made until an acceptable response is given.
A comma may be used instead of a semicolon after prompt string to suppress the question mark. For example, the following line prints the prompt with no question mark:
INPUT "ENTER BIRTHDATE",B$
If the prompt string is preceded by a semicolon, the RETURN key pressed by the operator is suppressed. During program execution, data on that line is displayed, and data from the next PRINT statement is added to the line.
When an INPUT statement is encountered during program execution, the program halts, the prompt string is displayed, and the operator types in the requested data. Strings that input to an INPUT statement need not be surrounded by quotation marks unless they contain commas or leading or trailing blanks.
When the operator presses the RETURN key, program execution continues.
INPUT and LINE INPUT statements have built-in PRINT statements. When an INPUT statement with a quoted string is encountered during program execution, the quoted string is printed automatically (see the PRINT statement).
The principal difference between the INPUT and LINE INPUT statements is that LINE INPUT accepts special characters (such as commas) within a string, without requiring double quotation marks, while the INPUT statement requires double quotation marks.
To find the square of a number:
10 INPUT X
20 PRINT X "SQUARED IS" X^2
The operator types a number (5) in response to the question mark.
5 SQUARED IS 25
To find the area of a circle when the radius is known:
20 INPUT "WHAT IS THE RADIUS"; R
40 PRINT "THE AREA OF THE CIRCLE IS"; A
60 GOTO 20
WHAT IS THE RADIUS? 7.4
THE AREA OF THE CIRCLE IS 171.9464
Note that line 20 in the above example makes use of the built-in PRINT statement contained within INPUT.
All Frank Sinatra recordings, All Beatles albums, All solo albums from John Lennon, Paul McCartney, George Harrison and Ringo Starr, All Beatles songs, List of Platinum selling albums, Database with hits from 1950 to 1999.
Sought after DLL files, Nutworks magazine (retro), Worldwide ISO and TLD codes, File extensions database, The Hackers dictionary, Free software for the Atari, Amiga and Macintosh, Nokia smartphone, PocketPC, List of all BASIC programming language commands, List of all DOS commands, Free Advanced Bash-Scripting Guide (Linux-Unix)