Qbasic Notes
Qbasic Notes
Introduction
BASIC ( Beginners All Purpose Symbolic Instruction Code) was first developed by a team of professors
John G. Kemeny and Thomas E. Kurtz of Dartmouth College, New Hampshire, USA, as a Computer
language for beginners and was implemented in the 1964.
BASIC is best suited for beginners as it helps in developing logical skills and is very user friendly
programming language.
Its commands or syntax (rules for writing statements) are very simple as they are written in common
English language. Debugging (removing error) in program of BASIC can be done easily.
QBASIC stands for Quick Beginners All Purpose Symbolic Instruction Code.
CHARACTER SET
A Character denotes any letter, digit, punctual mark, or any other sign used in the representation of
information in any language. It has the following character set:
1. Alphabets:
A,B,C, …….., Z (26 characters)
2. Numerals:
0,1,2,…., 9 (10 characters)
3. Special Characters:
-, +, *, /, &,^, $, <, >, etc.
CONSTANTS
Constants are those that do not change while executing the program. BASIC deals with 2 types of
constants.
Numeric Constants
All numbers belong to this category because their values remain constant.
String ConstantsA String Constant is any set of valid QBASIC characters enclosed in quotation marks. The
quotation mark do not form part of the string.
Eg. “Name”, “Delhi”, “a+b” , “56”
VARIABLES
Computer programs contain not only quantities that do not change but also quantities which change
during the execution. These quantities are called variables.
1. Numeric Variables
2. String Variables
Numeric Variables
Numeric variables can be any single letter of the alphabet or any single letter of the alphabet
followed by one of the numerals 0, 1, 2, ……,9. Or letters
Eg. A, B, C, ……., Z
A0,B0,…….., Z0
A1, B1, ……,Z1
.
.
.
.
A9,B9,……Z9
STRING VARIABLES
It should be remembered that any string variable can be used to store a string constant.
OPERATORS IN QBASIC
In QBASIC, a set of special symbols are used to indicate the nature of operations to be performed on the
given data. Such symbols are said as operators and the data items on which calculation is done are
called operands. There are three types of operators in QBASIC:-
1. Arithmetic Operators
2. Relational Operators
3. Logical operators.
ARITHMETICAL OPERATOR
The operator which operates on numeric constants and variables is said to be an Arithmetic operator. It
helps to do calculation to produce numeric output. Some arithmetic operators are :-
+ for addition
- For subtraction
*For multiplication
/ for division
^ for exponentiation
HIERARCHY OF OPERATIONS
The operators work and follow the same sequence in which they are used in mathematics ( i.e. as per
BODMAS rule). In computer it follows the rule of BEDMAS i.e.
Brackets ()
Exponents ^
Division /
Multiplication *
Addition +
Subtraction -
RELATIONAL OPERATOR
Relational Operators are used to compare two values. The relational operator checks the condition and
produces the results in either ‘True’ or ‘ False’ and further processing is done accordingly.
They are used to connect two or more relations and return a True or False value to be used in a decision.
AND conjunction
OR disjunction
2. X<1 or y>10