BASIC stands for Beginner’s All Purpose Symbolic Instruction Code. It was invented in 1963, at Dartmouth College, by the mathematicians George Kemeny and Tom Kurtzas
Every programming language has a set of rules that have to be followed while writing a program, following are some rules of QBASIC language :
Data is a collection of facts and figures that is entered into the computer through the keyboard. Data is of two types:
Data whose value does not change or remains fixed. There are two types of constants:
Numbers - negative or positive used for mathematical calculations e.g. −10, 20, 0
Numbers or alphabets written within double quotes(inverted commas “ “). e.g. “Computer”, “Operating System”
Data whose value is not constant and may change due to some calculation during the program execution. It is a location in the computer's memory, which stores the values. Depending on what value is held, Variables are of two types:
The variable that holds a Numeric Constant for arithmetic calculations (+, − ,⊸, e.g. A = 50, here A is the Numeric Variable
The variable that holds an Alphanumeric Constant, which cannot be used for arithmetic calculations, is called Alphanumeric Variable or String Variable. An Alphanumeric variable must end with a $ sign and the Alphanumeric constant must be enclosed in inverted commas. e.g. Name$ = “Akanksha”, here Name$ is an Alphanumeric Variable
The command is used to list the program on the screen.
The command is used to execute the program.
The command is used to list of program as a hardcopy.
The command is used to get the output of the program on the hard copy.
The command is used clear the memory of the existing program.
The command is used to take you back to dos prompt.
command can also be used without a line number. Print is used to view the display on the screen and CLS to clear the screen.
The command is used to show the position of the mistake.
The keyword is used to save the program. E.g. SAVE “PROGRAM1” QBasic will automatically add a period and an extension “bas” to the filename.
The keyword is used to LOAD the program from the disk to the memory. E.g. LOAD”PROGRAM1”
This command is used to clear the screen.
Print command is used to display the output on the screen. E.g. Print “HELLO WORLD!!!
It stands for Remark. It gives an explanation of the program or of the statements in the program thereby making the program more understandable to the reader. The computer does not execute this statement since whatever is written after REM is ignored by the compiler. REM can be used anywhere and many times in a program.
It assigns a value to a variable in a program. It stores a value in the memory location.
SYNTAX : LET<VARIABLE> ⩵< CONSTANT ⁄ VARIABLE or EXPRESSION >
E.g. Let A = 15…….. Assigning constant to a variable.
NOTE : A numeric data should be assigned to a Numeric variable and an alphanumeric data to an alphanumeric variable otherwise “TYPE MISMATCH” error is displayed.
This command is usually given at the end of the program. Statements written after end are not executed since the program terminates execution on reading this command.
This statement allows the user to enter a value for the variable while running the program. A question mark (?) appears on the output screen waiting for the user to enter a relevant data and then press enter key. Once the Return key or Enter key is pressed the data is stored in the variable.
SYNTAX : INPUT < VARIABLE >
E.g. Input A……Enter Numeric constant
To delete a line number in a program . e.g. Delete 10 will delete line number 10
Print with Semi-Colon (;) Semi-colon placed after the message to be displayed, leaves no space between two messages.
E.g. Print “This is an example” ; ”of QBasic program”
A QBasic program consist of lines containing.